Java的静态数组变量如何初始化
举例
class A{
char ch;
public void setCh(char _ch){
this.ch = _ch;
}
public char getCh(){
return this.ch;
}
}
public class Test{
static A arry[];
public static void Init(){
arry = new A[5];
for(char ch = 'A'; ch < 'E'; ch++){
arry[ch - 'A'].setCh(ch);
}
}
public staitc void main(){
Test.Init();
}
}
运行的结果是Exception in thread "main" java.lang.NullPointerException,我觉得是静态数组
static A arry[]错了,但是不知道arry[]应该怎么初始化,求救!