Answers for "comparing vs compare in java"

0

string compareto vs equals java

compareTo() when you need to know the difference in length between strings 
that start with the same sequence of characters.
  
  System.out.println("sumit".compareTo("timus"));//-1
Posted by: Guest on August-25-2021
1

string comparison using == in java

In Java Strings, the == operator is used to check the reference of both the string objects.
Use .equals method instead:
str1.equals(str2)
Posted by: Guest on December-13-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language