public class Student {
String id;
// String name;
Student() {
}
Student(String id) {
this.id = id;//this:当前对象的引用
System.out.println(this.id);
}
public static void main(String[] args){
Student stu1=new Student();
Student stu2=new Student("1");
System.out.println(stu1.id);
System.out.println(stu1);
}
}
不为null为啥,给stu2赋值了,stu1又没赋值
stu1无参构造出来的能不是null吗?赋值才不为null啊