I just realized that I didn't really address overloaded constructors. Here is a simple example:
public class Person {
String name;
int age;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
public Person(String name) {
// call other constructor with this name and 33
this(name, 33); // default age of 33
}
public static void main(String args[]) {
Person p1 = new Person("Bob", 22);
System.out.println(p1); // should print "Bob 22"
Person p2 = new Person("Sue");
System.out.println(p2); // should print "Sue 33"
}
public String toString() {
return name + " " + age;
}
}
Regards,
Jim