samedi 14 décembre 2019

Comparing between an Optional value with a normal variable doesn't work [duplicate]

This question already has an answer here:

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