Javaベース-コンストラクション関数


package com.base;

/**  *  * @author luyl  * @since 2012-03-15  */

public class ConstructorTest {  {   System.out.println("***" + " , 1");   System.out.println("***" + this.age);   System.out.println("***" + this.name);  }    // , ,  //System.out.println("***" + this.age);    private int age;  private String name;    private ConstructorTest(int age, String name){   this.age = age;   this.name = name;   System.out.println(" ");  }    {   System.out.println(" 2!");   System.out.println(this.age);   System.out.println(this.name);   this.age = 3;   this.name = "haha";   System.out.println(this.age);   System.out.println(this.name);  }

 /**   * @param args   */  public static void main(String[] args)  {   ConstructorTest c = new ConstructorTest(15, "xiaoming");   System.out.println(c.age);   System.out.println(c.name);

 }

} /* : *** , 1 ***0 ***null 2! 0 null 3 haha 15 xiaoming */

/**  * :  * 1. 。  *   public , new ;  *   , new ConstructorTest , 。  *   :java :private 。  *   friendly(default) ,protected ,public 。  *   ( ,java )  *    *  2. :  *  new  *    , 。int 0,String null。  *     *     */

 

:http://blog.csdn.net/chriscbz/article/details/4459733