java之子类对象实例化过程

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

假设现在有这么一个父类

public class Person{
    public Person(){}
    public String name = "tom";
    public int age = 1int sex = 0;
    void 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;
    }
}

有一个子类:

class Student extends Student(){
        super();
    }
    public String school;
}

那么进行Student stu = new Student();的过程如下:

猜你在找的Java相关文章