Array数组必须指定length
比如,
public class test{ private String name; private String pwd; private String[] account=new String[3]; public test(String a, String b,String c,String d,String f){ name=a; pwd=b; account[0]=c; account[1]=d; account[2]=f; //这地方不报空指针才怪 account[3]=f; } public static void main(String[] args){ test newTest = new test("1","2","2","2","2"); System.out.print(newTest.account[0]); } }