vendredi 27 octobre 2017

Java if statement returns opposite

i have this code:

try {
        String mode = readFile("fullScreen" , "0");
        if(mode == "fullScreen"){
            fullScreenBox.setSelected(true);
        }else{
            fullScreenBox.setSelected(false);
            System.out.println(mode);
        }
     } catch (URISyntaxException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
     }

the code Reads a File with name "fullScreen" if its not exists returns "0" i set an if statement. The file inside right "fullScreen" and i have a println over there to check it and indeed i get the word "fullScreen" but the program do the nagitave action.

what should be the error.

The problem is that i'm using the readFile and also if statements with other files in the same folder and works fine.

Aucun commentaire:

Enregistrer un commentaire