一个
空指针错误,请大家帮忙看看
各位高手:我用java写一个学生分数管理系统,就实现信息输入,求和,求平均分,排序的功能.全部代码如下,另外还有一个javabean.
package studentmanager;
import java.io.*;
public class StuSystem {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StuBean stbean[] = new StuBean[3];
//输入信息
public void InputInfor() {
System.out.println( "----------------请输入学生的成绩信息:------------ ");
try {
for (int i = 0; i < 3; i++) {
StuBean stu = new StuBean();
System.out.print( "学号: ");
stu.setCode(br.readLine());
System.out.print( "姓名: ");
stu.setName(br.readLine());
System.out.print( "C语言: ");
stu.setAverage(Float.parseFloat(br.readLine()));
System.out.print( "Java: ");
stu.setSum(Float.parseFloat(br.readLine()));
stbean[i] = stu;
System.out.println( "xuehao: "+stbean[i].getCourse1());//为什么输出是空的呢
System.out.println( "xuehao: "+stbean[i].getCourse2());());//为什么输出是空的呢
}
} catch (Exception ex) {
}
}
//求和
public void SetSum1() {
for (int i = 0; i < stbean.length; i++) {
stbean[i].setSum(stbean[i].getCourse1()+stbean[i].getCourse2());
System.out.println(stbean[i].getName()+ "的总分是: "+stbean[i].getSum());