Is there any way in which I can ignore case sensitivity in JAVA? If so, how do I do that?
**Please provide me with the code.
- Nathe
Four answers:
HandyManOrNot
2009-02-19 23:49:06 UTC
When comparing Strings, just use toLowerCase() or toUpperCase() methods on each String prior to comparison, or the equalsIgnoreCase(String) method.
2016-12-08 23:25:51 UTC
Case Sensitive Java
2009-02-19 23:46:38 UTC
Java code is case sensitive. Period. If you want to make it so strings aren't case sensitive, you can do a String.toLowercase() or similar command so it always becomes all lowercase and therefore the string itself won't be case sensitive anymore.
Fudge
2009-02-19 23:47:53 UTC
u can use Case Sensitivity Strings contents
for example :
String name1= "foo";
String name2 = "FOO");
if ( name1.equalsIgnoreCase( name2 )) {//code }
However NOT for Java keywords or variables names are case SENSITIVE
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.