不知道这是怎么回事?
if(!strl[0].equals("")&&!strl[1].equals("")&&!strl[2].equals("")&&!strl[3].equals("")&&!strl[4].equals("")&&!strl[5].equals("")) {strl[6] = jcb.getSelectedItem().toString();
sql = "insert into student (StuNO, StuName , StuSex, Class, Department, Password, Permitted) values('" +
strl[0]+"','" + strl[1]+"','" + strl[2]+"','" +strl[3]+"','" + strl[4] +"','"+strl[5]+"','" +strl[6]+"')";
db = new DataBase();
int i=db.updateDb(sql);
if(i==1) {
JOptionPane.showMessageDialog(this,"添加成功!","提示",JOptionPane.INFORMATION_MESSAGE);
return; }
else {
JOptionPane.showMessageDialog(this,"添加失败!","提示",JOptionPane.INFORMATION_MESSAGE);
return;
}
Vector<String> v = new Vector<String>();
for(int j=0; j<6; j++) {
v.add(strl[j]);
if(j<6) {
jf[j].setText("");
}
}
这么写的时候,就会在Vector<String> v = new Vector<String>();显示有错误
但是这样写的时候:
if(!strl[0].equals("")&&!strl[1].equals("")&&!strl[2].equals("")&&!strl[3].equals("")&&!strl[4].equals("")&&!strl[5].equals("")) {
strl[6] = jcb.getSelectedItem().toString();
sql = "insert into student (StuNO, StuName , StuSex, Class, Department, Password, Permitted) values('" +
strl[0]+"','" + strl[1]+"','" + strl[2]+"','" +strl[3]+"','" + strl[4] +"','"+strl[5]+"','" +strl[6]+"')";
db = new DataBase();
db.updateDb(sql);
Vector<String> v = new Vector<String>();
for(int j=0; j<6; j++) {
v.add(strl[j]);
if(j<6) {
jf[j].setText("");
}
}
就没有显示错误了,请问这是怎么回事?