/** * this关键字用法 */ public class Flower { int petalCount = 0; String s = "initial value"; Flower(int petals){ petalCount = petals; System.out.println("Constructor with one int arg"); } Flower(String ss){ System.out.println("Constructor with one string arg"); s = ss; } Flower(String ss, int petals){ this(petals); this.s = ss; System.out.println("Constructor with string and int args"); } Flower(){ this("hi",47); System.out.println("Default Constructor with no args"); } void printPetalCount(){ System.out.println("petalCount = "+petalCount+"; s = "+s); } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Flower x = new Flower(); x.printPetalCount(); } }