public class College{
int year;
String name;
College(int year,String name){
year=year;
name=name;
}
public static void main(String[] args) {
College first=new College(1998,"BITS");
System.out.println("The year is:"+first.year);
System.out.println("The name is:"+first.name);
}
}
我的输出是:年份是0
名字是null
这怎么样?据我说,对象首先不能直接访问私有数据成员。