hi i'am trying to check is user input is "e" or not but when i use if(input == "e") it always get false even if i enter "e" , i do not know why
public static void main(String [] args)
{
Scanner in =new Scanner(System.in);
LinkedList<Integer> lst = new LinkedList();
String input = in.nextLine();
while (isInt(input)) {
lst.add(Integer.parseInt(input));
input = in.nextLine();
}
// this if statement always false
if(input=="e")
{
Collections.sort(lst);
for(int item: lst) {
System.out.println(item);
}
}
}
Aucun commentaire:
Enregistrer un commentaire