Still more (scandalously basic) trivia!
Also, there's no reason you can't have a
private constructor if you really, really want one. Don't let kill-joys tell you there is. Here, have a look at this:
// For your pleasure alone, I have used hardlinks in lieu
// of syntax highlighting. Enjoy.
public class LookyHere extends FancySecretSuperClass {
private LookyHere (String str) {
super(str); //this string does something important
}
public LookyHere (Integer i) {
this(i.toString());
}
public LookyHere (Object o) {
this(o.toString());
}
public LookyHere (char[] chrs) {
this(new String(chrs));
}
// etc.
}
It makes sense in the same way
using accessors to fiddle with your member variables does. Granted, it's kind of a
trivial example. (I had intended to pass in the different possible parameters for a Connection object, but I'm lousy at that database stuff and
it would never have compiled. Hell, even this may not compile. It's just an illustration of my argument.)