I've found a task on some Java programming competition. One must create class Sentence with only one argument 'text' and only one constructor. Here's sample test code :
Sentence s1=new Sentence("only","CAT"),
s2=new Sentence("and", 2, "mice"),
s3=new Sentence(s1,s2,"completely","alone"),
s4=new Sentence(s3, "on the ", new Integer(32), "th street");
System.out.println(s1); Only cat.
System.out.println(s2); Only cat and 2 mice.
System.out.println(s3); Only cat and 2 mice completely alone.
System.out.println(s4); Only cat and 2 mice completely alone on the 32th street.
How one contructor can serve different sets of arguments ? Is there something like dynamical constructor which recognizes sent values?