This question already has an answer here:
- How do I compare strings in Java? 23 answers
I tried to compare between these two variables but it always gave false
System.out.println(file_ext.get().toLowerCase() == "txt");
if (file_ext.get() == "txt") {
System.out.println("Started");
} else {
System.out.println("Incompatible file extension:" + file_ext.get());
}
but it prints this in the output:
false
Incompatible file extension:txt
Aucun commentaire:
Enregistrer un commentaire