Student s =new Student();完成了那些事情?

简介: Student s =new Student();完成了那些事情?
class student{
  private String name;
  private int age;
  public Student(){}
  public Student(String name,int age){
    this.name = name;
    this.age = age;
  }
  setXxx()/getXxx()
}
public static void main(String[] args){
  Student s = new Student();
}

1)将Student.class字节码文件加载进内存

2)Student s 在栈内存开辟空间

3)new Student(); 在堆内存中申请空间

4)执行Student() 无参构造方法,进行系统默认初始化

name : null age : 0

5)执行显示初始化,通过公共的setXxx()

给成员变量赋值实际值

name : 张三 age : 20

6)初始化完毕,在堆内存中产生一个空间地址值

7)将当前堆内存中,空间地址值给栈内存的变量s

目录
打赏
0
0
0
0
1
分享
相关文章
Jsp自定义标签(foreach,dept,select)
Jsp自定义标签(foreach,dept,select)
56 0
【PAT甲级 - C++题解】1047 Student List for Course
【PAT甲级 - C++题解】1047 Student List for Course
117 1
MongoTemplate 多表查询中 将String转换为ObjectId
MongoTemplate 多表查询中 将String转换为ObjectId
313 0
定义Student类
定义Student类
160 0
【PAT甲级 - C++题解】1039 Course List for Student
【PAT甲级 - C++题解】1039 Course List for Student
82 0
用无限套娃的extends做一个teacher and student案例
用无限套娃的extends做一个teacher and student案例
108 0
用无限套娃的extends做一个teacher and student案例
Student:T4M3 Sean
一,自我情况 二,使用过程 三,心得体会,
Student:T8M2 Tammy
在第一次使用时,平台还提供了教程,只需要用心花点时间完成其中的场景实践和技能自测就可以啦。并且每一步都有很详细的教程,包括如何体验ECS云服务器的新手场景以及了解其中的概念和基础操作。对于我这种之前没使用过云服务器的人来说真的非常友好。
Student:T9M1 sean
在第一次使用时,平台还提供了教程,只需要用心花点时间完成其中的场景实践和技能自测就可以啦。并且每一步都有很详细的教程,包括如何体验ECS云服务器的新手场景以及了解其中的概念和基础操作。对于我这种之前没使用过云服务器的人来说真的非常友好。