我尽量简单写,问题在后边注释里,谢谢大家了.
private int good; //上边是类的开头不写了
private String[] common=new String[this.good]; //定义一个int 变量和字符串数组;
public temp(int num) {
this.good=num; //建对象时给变量good 赋值
System.out.println(this.good); //输出是5 ,没毛病
System.out.println(common.length); //问题来了 这时候输出的是0;请问是为什么????我该怎么改
}
public static void main(String[] str) {
temp tm=new temp(5);
}
}
private int good; //上边是类的开头不写了
private String[] common=new String[this.good]; //定义一个int 变量和字符串数组;
public temp(int num) {
this.good=num; //建对象时给变量good 赋值
System.out.println(this.good); //输出是5 ,没毛病
System.out.println(common.length); //问题来了 这时候输出的是0;请问是为什么????我该怎么改
}
public static void main(String[] str) {
temp tm=new temp(5);
}
}












