当前位置: 技术问答>java相关
String[]字符串数组问题?----在线等,100分
来源: 互联网 发布时间:2017-03-29
本文导语: private String[] grade = null; //等级标准 private int[] max_score; //最大值标准 private int[] min_score; //最小值标准 …… sql = "select count(GRADE) from EVAL_GRADE where EVAL_CODE = ?"; …… RS = mysql.executeQuery(); int m ; if(RS.next()){ ...
private String[] grade = null; //等级标准
private int[] max_score; //最大值标准
private int[] min_score; //最小值标准
……
sql = "select count(GRADE) from EVAL_GRADE where EVAL_CODE = ?";
……
RS = mysql.executeQuery();
int m ;
if(RS.next()){
m = RS.getInt(1);
grade = new String[m];
max_score = new int[m];
min_score = new int[m];
}
……
sql = "select GRADE,MAX_SCORE,MIN_SCORE from EVAL_GRADE where EVAL_CODE = ?";
RS = mysql.executeQuery();
m =0;
……
while(RS.next()) {
m++;
grade[m] = RS.getString(1); //错误在此处 error:
max_score[m] = RS.getInt(2);
min_score[m] = RS.getInt(3);
}
……
--------------------------------------------------------
DEBUG:
ERROR:
java.lang.ArrayIndexOutOfBoundsException
private int[] max_score; //最大值标准
private int[] min_score; //最小值标准
……
sql = "select count(GRADE) from EVAL_GRADE where EVAL_CODE = ?";
……
RS = mysql.executeQuery();
int m ;
if(RS.next()){
m = RS.getInt(1);
grade = new String[m];
max_score = new int[m];
min_score = new int[m];
}
……
sql = "select GRADE,MAX_SCORE,MIN_SCORE from EVAL_GRADE where EVAL_CODE = ?";
RS = mysql.executeQuery();
m =0;
……
while(RS.next()) {
m++;
grade[m] = RS.getString(1); //错误在此处 error:
max_score[m] = RS.getInt(2);
min_score[m] = RS.getInt(3);
}
……
--------------------------------------------------------
DEBUG:
ERROR:
java.lang.ArrayIndexOutOfBoundsException
|
grade[m] = RS.getString(1); //错误在此处 error:
max_score[m] = RS.getInt(2);
min_score[m] = RS.getInt(3);
m++;
----------------
当发现错误时,要先跟踪以下看一看。
max_score[m] = RS.getInt(2);
min_score[m] = RS.getInt(3);
m++;
----------------
当发现错误时,要先跟踪以下看一看。