Il metodo di String equalsIgnoreCase
equalsIgnoreCase
public boolean equalsIgnoreCase(String anotherString)
- Compares this
String
to anotherString
, ignoring case considerations. Two strings are considered equal ignoring case if they are of the same length and corresponding characters in the two strings are equal ignoring case.Two characters
c1
andc2
are considered the same ignoring case if at least one of the following is true:- The two characters are the same (as compared by the
==
operator) - Applying the method
Character.toUpperCase(char)
to each character produces the same result - Applying the method
Character.toLowerCase(char)
to each character produces the same result
- The two characters are the same (as compared by the
- Parameters:
anotherString
- TheString
to compare thisString
against- Returns:
true
if the argument is notnull
and it represents an equivalentString
ignoring case;false
otherwise
Esempio:
String nome="Mario"; ... nome.equalsIgnoreCase("Mario") ritorna true ... nome.equalsIgnoreCase("Maria") ritorna false ... nome.equalsIgnoreCase("maRiO") ritorna true ... nome.equalsIgnoreCase("maRiA") ritorna false
Ultime modifiche: venerdì, 16 novembre 2012, 09:40