源程序:
class Person{
public Person(){
System.out.println("一个新的Person对象产生了") ;
}
}
public class Test{
public static void main(String args[]){
System.out.println("声明对象:Person per = null") ;
Person per = null ;
System.out.println("实例化对象:per = Person()") ;
per = new Person() ;
}
}
运行结果:
![java <wbr>声明一个构造方法 java <wbr>声明一个构造方法](https://i-blog.csdnimg.cn/blog_migrate/a4c26d1e5885305701be709a3d33442f.gif)