0

I write an object to a file and then I read it.

Then I make "if" to compare object's arguments. For example "genreDescription" is "Action".

 if (genreDescription == "Action" ) { System.out.println("Some text"); } 

Before import == and equals produce expected and the same result. After import equals work but == doesn't. I tried removing blank spaces. I also manually updated object's "genreDescription" to "Action" right before if. It affects only String, because if "gendreDescription" is int like 6 then it's normal. Why?

3
  • I red these topics but they don't explain why it affects only Strings and not ints. Can you say that? Commented May 11, 2020 at 4:40
  • Strings are objects ints not. Commented May 11, 2020 at 4:46
  • JAVA Strings are mapping in heap memory , so compareing strings is comparing their address Commented May 11, 2020 at 5:21

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.