Search
 
SCRIPT & CODE EXAMPLE
 

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
} 
Comment

compare two character alphabetically java

return Character.toLowerCase(ch1) < Character.toLowerCase(ch2);
Comment

java compare strings alphabetically

Different 'Collation Strength' values give different sort results: 
[Äbc, äbc, Àbc, àbc, Abc, abc, ABC] - Original Data
[Äbc, äbc, Àbc, àbc, Abc, abc, ABC] Primary
[Abc, abc, ABC, Àbc, àbc, Äbc, äbc] Secondary
[abc, Abc, ABC, àbc, Àbc, äbc, Äbc] Tertiary

Case kicks in only with Tertiary Collation Strength  : 
[cache, CACHE, Cache] - Original Data
[cache, CACHE, Cache] Primary
[cache, CACHE, Cache] Secondary
[cache, Cache, CACHE] Tertiary

Accents kick in with Secondary Collation Strength.
Compare with no accents present: 
Collator sees them as the same : abc, ABC - Primary
Collator sees them as the same : abc, ABC - Secondary
Collator sees them as DIFFERENT: abc, ABC - Tertiary

Compare with accents present: 
Collator sees them as the same : abc, ÀBC - Primary
Collator sees them as DIFFERENT: abc, ÀBC - Secondary
Collator sees them as DIFFERENT: abc, ÀBC - Tertiary
Comment

PREVIOUS NEXT
Code Example
Java :: javafx text wrapping 
Java :: sum of list java 
Java :: how to change theme of app in android studio programmatically 
Java :: java parseint 
Java :: java if or 
Java :: number of digits java 
Java :: java bean 
Java :: code for checking android build version 
Java :: uppercase java 
Java :: fill two dimensional array rows by rows java 
Java :: how to make a loop in java 
Java :: java time difference 
Java :: android @Parcelize not resolving 
Java :: iterate through an arraylist java 
Java :: formatting an integer in java 
Java :: how to fill a 2d array in java 
Java :: java system.out.println 
Java :: java interface attributes 
Java :: difference between object and class 
Java :: skip values in a for loop java 
Java :: java square root 
Java :: max and min array number in java 
Java :: java look and feel system 
Java :: throw error java 
Java :: tomcat 9 default username and password 
Java :: hexstring to string In java 
Java :: print string in java 
Java :: how to change color of drawable in android 
Java :: Changing background color of selected item in recyclerview 
Java :: math.min java 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =