당신은 여기에 코드 오류가 있지만 각각의 모든 라인이 올바르게 보이지만이 코드는 내 응용 프로그램에서 사용되는 경우 "if"문을 작동하지 않습니다에서 볼 수있는 것 .... .. 문자열이 이미 존재하는 문자열 배열과 일치하지 않습니다. if 문을 제거하면 모든 반복에 대해 잘 작동합니다. (나는 동일한 엔티티를 넣음으로써 검사했으나 여전히 작동하지 않습니다)어떤 오류가있을 수 있습니다
이유를 알고 싶습니다. .... ??? 감사합니다
는참고 :
- (S1)은 (비어 있지 않은) 문자열입니다 '(비어 있지 않은)
- searchentry 문자열 배열입니다'
코드 :
public void searchCapability(){
boolean NotFound=true;
///////////////// Linear Folder Search /////////////
for(int i=0; i<s1.length; i++){
if(searchentry==s1[i]){ // code under this if is not working as if is true or false
l1.setSelectedIndex(i);
NotFound=false;
}
}
/////////////////// Linear File search /////////////
for(int i2=0; i2<s2.length; i2++){
// code under this if is not working as if is true or false
if((searchentry+".xls")==s2[i2]){
l2.setSelectedIndex(i2);
t1.setText(s3);
NotFound=false;
}
}
if(NotFound==true){
JOptionPane.showMessageDialog(null, "Entry Not Found :)", "Error", JOptionPane.INFORMATION_MESSAGE);
}
}
가능한 중복 http://stackoverflow.com/questions/513832/ 값을 비교 how-do-i-compare-strings-in-java) –