Question:
ignore case. java problem?
Kody Smith
2011-10-05 15:22:31 UTC
i have this line
month = keyboard.nextLine();
and I want java to ignore case sensitivity. what do I add to the line? I know there's a word we add but I forgot what it was
Three answers:
McFate
2011-10-05 15:24:53 UTC
toUppercase()/toLowercase() will return a copy of the entire String converted to the given case. You can use that to turn the casing into a predictable state.



You can use .equalsIgnoreCase() instead of .equals() when comparing strings to ignore case, if you don't know the case and don't want to bother converting.
Lynn
2016-03-02 01:41:12 UTC
gethu jiiiiiiiiiiiii
?
2011-10-05 19:16:36 UTC
This will make input capital

month = ( keyboard.nextLine() ).toUpperCase( );

or this will make input smaller

month = ( keyboard.nextLine() ).toUpperCase( );


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...