Ask your own question, for FREE!
Computer Science 25 Online
OpenStudy (woodrow73):

When creating multiple classes in Java to create objects...

OpenStudy (woodrow73):

This is a question about constructors: I've noticed the StringBuilder class has an interesting trait- it has 3 different types of constructors (StringBuilder object = new StringBuilder(<constructor goes here>);) If you put in a string, the string will save to the class-type variable 'object', if you input a number, the string in object will have a size of the length you input (don't know what that really means..) & no constructor will automatically assign a size of 16 to the variable 'object' Now that I'm creating my own API's, (series of prewritten classes & methods)** (application programmer interface) When I make the constructor, let's say the constructor's parameters are (int A, int B). So, when I call on the class with those constructors into an object, if I don't input the constructors in the exact orientation as the parameters, I will get an error... After seeing how the constructor of a StringBuilder class can either be nothing, an int, or a String, I know that having a class with 'flexible arguments' is possible. How would I go about this?

OpenStudy (woodrow73):

solved it myself :D

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!