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)这是为什么呢?
程序本身没什么错误

解决方案 »

  1.   

    晕,这还没错误?
    你的i数组是null,引用的时候当然要出现NullPointerException了。
      

  2.   

    byte[] i = null;~~~ ||**||
      

  3.   

    System.in.read用的不舒服
    上午脑袋发热!
    高手们看了别笑呵呵
    考虑了一下程序已经搞定了!!
    package test;import java.io.*;public class test { public static void main(String[] args)throws IOException {
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            
    String str=br.readLine();
    System.out.println(str);
    int i=Integer.parseInt(str);
    String j=new String();
    j=(i>=90)?"A":((i>=60)?"B":"C");
    System.out.println(j); }}现在没问题了!!