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

前端之家收集整理的这篇文章主要介绍了java之简单类对象实例化过程前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

假设现在有这么一个类:

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

Person p = new Person();

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

猜你在找的Java相关文章