How to compare strings in Java
In Java, we use equals() to compare string value. In this article, we will show you a few ways to compare strings in Java: using equals(), using equalsIgnoreCase(), using contentEquals(),…
Favourite tutorials for developers
In Java, we use equals() to compare string value. In this article, we will show you a few ways to compare strings in Java: using equals(), using equalsIgnoreCase(), using contentEquals(),…
The Java String compareTo() method compares two strings lexicographically (alphabetical order). It returns a positive number, negative number, or zero. if s1 < s2, it returns negative number. if s1…