My main constructor does stuff, my 'helper' (sorry, not up on OO terminology) constructors call the main constructor with various defaults:
Is this forbidden, or am I missing some syntactical sugar?
Code:
public class Broken {
private int foo;
Broken() {
Broken(0); // Gives 'error: cannot find symbol'
this.Broken(1); // Ditto
}
Broken(int bar) {
foo = bar;
}
private void show(String why) {
System.out.println(why + foo);
}
public static void main(String[] args) {
Broken b = new Broken();
Broken b2 = new Broken(42);
b.show("broken() ");
b2.show("broken(42) ");
}
}