Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java compare strings alphabetically

String a = "HYRE"; 
String b = "AGNYG";  

int compare = a.compareTo(b);  

if (compare < 0) {  
    //a is smaller
}
else if (compare > 0) {
    //a is larger 
}
else {  
    //a is equal to b
} 
 
PREVIOUS NEXT
Tagged: #java #compare #strings #alphabetically
ADD COMMENT
Topic
Name
3+6 =