The following are top 10 frequently asked questions about Java Strings.
1. How to compare strings? Use “==” or use equals()?
In brief, “==” tests if references are equal and equals() tests if values are equal. Unless you want to check if two strings are the same object, you should always use equals().