我正在尝试阅读这个名单和电话号码列表。但该程序一直在抛出nullpointerexception。为什么要这样做?
int i=0;
Datab[] b = null;
//b = null;
// The name of the file to open.
String fileName = "datt.dat";
try {
// Use this for reading the data.
byte[] buffer = new byte[1000];
FileInputStream FileIS = new FileInputStream("datt.dat");
ObjectInputStream input = new ObjectInputStream(FileIS);
for(i=0; i<b.length; i++)
b[i]=(Datab)input.readObject();
input.close();
答案 0 :(得分:1)
b为null,因此b.length抛出异常