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 :: check character is alphanumeric java 
Java :: change color of action bar android studio 
Java :: java cheat sheet 
Java :: spring boot intellij auto reload 
Java :: java parallel sort 
Java :: android kotlin center text 
Java :: how to add music to java 
Java :: java 8 filter first 
Java :: isinstance java 
Java :: java substring 
Java :: java create file and parent directories 
Java :: java or symbol 
Java :: java try catch 
Java :: java array declaration 
Java :: java join list as string 
Java :: export java home 
Java :: get absolute path from relative java 
Java :: how to resize image in android programmatically 
Java :: array liste java 
Java :: android toast message 
Java :: java 8 list stream delete by name 
Java :: qr code generator in java 
Java :: parse string to int java 
Java :: java parse unix timestamp 
Java :: java print hello world 
Java :: string to bigdecimal 
Java :: android studio constraint layout proportional height 
Java :: java convert to roman numerals 
Java :: Java how to make a number with digits 
Java :: keytool error: java.io.FileNotFoundException: my-release-key.keystore (Access is denied) java.io.FileNotFoundException: my-release-key.keystore (Access is denied) 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =