- //声明个人的类
- class Person
- {
- private String name;
- private int age;
-
- Person(String name,int age){
- this.name = name;
- this.age = age;
- System.out.println("name = "+name+",age = "+age);
- }
-
- }
- class PersonDemo
- {
- public static void main(String[] args) {
- Person p3 = new Person("li",16);
- }
- }
复制代码 建立类时,构造函数在栈内执行顺序如何,先在堆内建立空间,辅地址再传参,还是传参完成再赋地址给对象名变量啊?
|