
Java – How to compare strings
== is to compare 2 object whether are of the same reference equality (whether they are the same object). .equals() tests for value equality (whether they are logically “equal”). Objects.equals() checks for null before calling .equals() so you don’t have to check null to avoid NPE. (available since JDK7, also available in Guava). String.contentEquals() compares... » read more