我将此数据存储在10x5矩阵中,但是当我到达第一行的4位置时,我遇到了此错误“线程中的异常”AWT-EventQueue-0“java.lang.ArrayIndexOutOfBoundsException:5”。我认为错误在listPatients[0][counter]中,但我不知道该怎么办。
public class PatientForm extends javax.swing.JFrame {
Patient[][] patientList;
int counter;
public PatientForm() {
initComponents();
patientList = new Patient[10][5];
counter = 0;
}
private void btnasignarActionPerformed(java.awt.event.ActionEvent evt) {
if (counter < listPatients.length) {
String identification = txtidentification.getText();
String name= txtname.getText();
String lastName = txtlastName.getText();
String eps = txteps.getText();
boolean type = jrbtipo1.isSelected();
String diagnosis = txtdiagnostico.getText();
Patient objPatient = new Patient(identification, name, lastName, eps, type, diagnosis);
listPatients[0][counter] = objPatient;
counter++;
JOptionPane.showMessageDialog(this, "Head" + counter + " Patients.");
}else {
JOptionPane.showMessageDialog(this, "Error", "Error", JOptionPane.ERROR_MESSAGE);
}
}
}
动漫人物
相关分类