java之简单类对象实例化过程

假设现在有这么一个类:

public class Person{
    public Person(){}
    String name = "tom";
    int age = 1;
    int sex = 0;
    public void showInfo(){
        System.out.println(this.name);
        System.out.println(this.age);
        System.out.println(this.sex);
    }
    public void seInfo(String name, int age, int sex){
        this.name = name;
        this.age = age;
        this.sex = sex;
    }
}

Person p = new Person();

那么整个对象的创建过程如下:

猜你喜欢

转载自www.cnblogs.com/xiximayou/p/12048783.html
今日推荐