-2

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.

1 Answers1

0

Strings are objects. You can't use == with strings for comparison, you have to use String.equals(Object).

So you should change your code to this:

if (mode.equals("fullScreen")) {
Nilkun
  • 51
  • 5