my code work fine until i add the else bit
String getInputSearch = JOptionPane.showInputDialog("city")
for(int i=0; i < listArray.length; i++) {
if(getInputSearch == loadData()[i][0]) {
for(int j=0; j< loadData()[i].length; j++) {
println(loadData()[i][j])
}
println("")
}
else{
println( getInputSearch+ "not a valid city");
}
}
if i add a break to the else bit, the loop only works once and if i dont it keeps printing not a valid city, even if the city is valid until it reaches the the right index in the array. (data is read from a text file btw) help would be appreciated.
Aucun commentaire:
Enregistrer un commentaire