String Comparison in Java
== compares references (same object in memory). equals compares characters. new String("Hi") twice → == is false, equals is true.
Literals "Hi" == "Hi" can be true because of the String Pool. User input and new String(...) almost never match with ==. Always equals for content.
equalsIgnoreCase ignores capital letters. compareTo gives ordering, not just true/false.
Let's take this on the board with one tiny Main class — no extra files. String Comparison in Java — output: false then true. new String("Hi") twice = two objects (== false). equals checks the text Hi. Start from main, go line by line, and stop at each print. That output is the proof for String Comparison.
new String("Hi") new String("Hi")
│ │
└─ == false
└─ equals trueShow new String("Hi") twice: == false, equals true. That is the whole answer.