Answers for "comparetoin java"

C
4

how to compareTo in java

x.compareTo(y) <  0     // x <  y
x.compareTo(y) <= 0     // x <= y
x.compareTo(y) != 0     // x != y
x.compareTo(y) == 0     // x == y
x.compareTo(y) >  0     // x >  y
x.compareTo(y) >= 0     // x >= y
Posted by: Guest on November-30-2021
0

java compareTo

String s1 = "2"
String s2 = "5"
s1.compareTo(s2); //returns difference between 2 Strings
3 	//returns positive 3 since s2 string is higehr than s1 by 3
Posted by: Guest on May-06-2022

Code answers related to "C"

Browse Popular Code Answers by Language