C 배경에서 왔기 때문에 잘못된 구문이 있다고 가정합니다.중첩 된 If 문 FAILing
다음 코드에서; 내가} '라인 X, 조기 EOF에 예기치 않은 말을 컴파일 오류를 얻고있다. 나는 map.containsKey을 evalute 하위 IF를 (ID)는 컴파일을 제거하고 내가 인터넷에서 읽은 좋은. 모두를 실행하는 경우
public class ButtonListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
String jcbValue = (String) jcbIDF.getSelectedItem();
if (jcbValue.equals("Insert")) {
String Id = jtfId.getText();
ArrayList<String> ValueList = new ArrayList<String>();
String Name = jtfName.getText();
String GPA = jtfGPA.getText();
ValueList.add(Name);
ValueList.add(GPA);
if (map.containsKey(Id)){
JOptionPane.showMessageDialog(null, "Key exists!",
"Result", JOptionPane.INFORMATION_MESSAGE);
}
else if (!map.containsKey(Id)){
map.put(Id, ValueList);
System.out.println(map);
JOptionPane.showMessageDialog(null, "Record inserted",
"Result", JOptionPane.INFORMATION_MESSAGE);
jtfId.setText("");
jtfName.setText("");
jtfGPA.setText("");
}
} //terminates insert
else if (jcbValue.equals("Delete")) {
String Id = jtfId.getText();
ArrayList<String> ValueList = new ArrayList<String>();
String Name = jtfName.getText();
String GPA = jtfGPA.getText();
if (map.containsKey(Id)){
JOptionPane.showMessageDialog(null, "Key exists, deleted!",
"Result", JOptionPane.INFORMATION_MESSAGE);
} else if (!map.contasKey(Id)){
System.out.println(map);
JOptionPane.showMessageDialog(null, "Key Does not exist!",
}
} //terminates delete
else if (jcbValue.equals("Find")) {
System.out.println(map);
JOptionPane.showMessageDialog(null,
"Find Selected; But not Implemented", "Result",
JOptionPane.INFORMATION_MESSAGE);
} //terminates find
}// Terminates actionPerformed Class
}// Terminates ButtonListenerClass
자바 그렇게 정확히 누구인지 내가 잘못하고?
감사를 도와, 문 IF 중첩 할 수 말한다!
CJ
빠른 응답 주셔서 감사합니다. 문제를 확인하고 디버거 유형을 사용 했습니까? – CryptoJones
스폿을 확인했습니다. "Unexpected}"는 뭔가 다른 것을 기대하고 있었을 때 문제 코드를 찾을 때까지 각각의 앞에 있었던 것을 보았습니다. 이클립스와 같은 IDE는 이런 종류의 문제를 강조해야한다. –