Esta cuestión se puede abordar de diversas formas, por lo tanto te damos la que para nosotros es la solución más completa.
Ejemplo 1: Java compara cadenas alfabéticamente
String a ="HYRE";String b ="AGNYG";int compare = a.compareTo(b);if(compare <0)//a is smallerelseif(compare >0)//a is larger else//a is equal to b
Ejemplo 2: Java compara cadenas alfabéticamente
Different'Collation Strength' values give different sort results:[Äbc, äbc, Àbc, àbc,Abc, abc, ABC]-OriginalData[Äbc, äbc, Àbc, àbc,Abc, abc, ABC]Primary[Abc, abc, ABC, Àbc, àbc, Äbc, äbc]Secondary[abc,Abc, ABC, àbc, Àbc, äbc, Äbc]TertiaryCase kicks in only withTertiaryCollationStrength:[cache, CACHE,Cache]-OriginalData[cache, CACHE,Cache]Primary[cache, CACHE,Cache]Secondary[cache,Cache, CACHE]TertiaryAccents kick in withSecondaryCollationStrength.
Comparewithno accents present:Collator sees them as the same : abc, ABC -PrimaryCollator sees them as the same : abc, ABC -SecondaryCollator sees them as DIFFERENT: abc, ABC -TertiaryComparewithaccents present:Collator sees them as the same : abc, ÀBC -PrimaryCollator sees them as DIFFERENT: abc, ÀBC -SecondaryCollator sees them as DIFFERENT: abc, ÀBC -Tertiary
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)