错误有关问题,程序本身没异常
阅读
package test.io;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class testaaa {
public static void main(String[] args) {
byte[] i = null;
int score = 0;
try {
score = System.in.read(i);
} catch (IOException e) {
e.printStackTrace();
}
String str=new String();
str=(score> =90)? "A ":((score> =60)? "B ": "C ");
System.out.println(str);
}
}
异常为
Exception in thread "main " java.lang.NullPointerException
at java.io.FilterInputStream.read(Unknown Source)
at test.io.testaaa.main(testaaa.java:14)
这是为什么呢?
程序本身没什么错误
------解决方案--------------------
谁说程序本身没错误?
------解决方案--------------------
晕,这还没错误?
你的i数组是null,引用的时候当然要出现NullPointerException了。
------解决方案--------------------
byte[] i = null;~~~ ||**||
------解决方案--------------------
o_o
------解决方案--------------------
new 一下就ok啦~~
阅读
上一篇:java连接SQL Server 2000在有关问题 下一篇:返回列表