Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 799731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:10:39+00:00 2026-05-14T23:10:39+00:00

What are the use cases of having two constructors with the same signature? Edit:

  • 0

What are the use cases of having two constructors with the same signature?

Edit: You cannot do that in Java because of which Effective Java says you need static factory. But I was wondering why would you need to do that in the first place.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:10:39+00:00Added an answer on May 14, 2026 at 11:10 pm

    The reason you’d think you wanted to do this is that you’ve found yourself in a situation where variable type isn’t sufficient context.

    For example, I might fool myself into thinking that I need to give my Point class two constructors: one which works by X and Y, and one by degrees and radians. Both might be represented as float.

    So I’d think I needed two constructors with identical signatures (float, float).

    Dr. Bloch points out that it’s better to make factory methods:

    
        public static Point newPointByDegreesAndRadians (float degrees, float radians);
        public static Point newPointByXandY (float x, float y);
    

    Incidentally, another alternative to factory methods is to create types which carry the context which is missing from the datatypes, like this:

    
        public class CoordinatesXY {
           float X;
           float Y;
           ...
        }
        public class CoordinatesDegreesRadians {
           float degrees;
           float radians;
           ...
        }
        public Point (CoordinatesXY coordinates) { ... }
        public Point (CoordinatesDegreesRadians coordinates) { ... }
    

    Whether you think this is clearer than the factory methods is a matter of taste. For this specific case, my own feeling is that the two coordinates classes are only of use if your design makes coordinates useful on their own, separate from a point at those coordinates.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having problems with something that should be simple. I have two use cases...
I'm trying to understand which of the two to use, having four main criteria
What are the best practices for using use cases to model system behavior that
I am new to writing use cases.I heard that Use cases are non-technical expressions
I know there are many cases which are good cases to use multi-thread in
I have two classes that I use to access two different tables in my
I'm trying to create two side-by-side div elements, but I found that having an
What are the best use cases for anonymous types? It would seem to me
I need to write a use cases to test the asp.net mvc applicatoin. How
I would like to know a few practical use-cases (if they are not related/tied

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.