The Character class of Java API has various functions you can use.

You can convert your char to lowercase at both sides:

Character.toLowerCase(name1.charAt(i)) == Character.toLowerCase(name2.charAt(j))

There are also a methods you can use to verify if the letter is uppercase or lowercase:

Character.isUpperCase('P')
Character.isLowerCase('P') 
Answer from Shehzad on Stack Overflow
Top answer
1 of 6
75

The Character class of Java API has various functions you can use.

You can convert your char to lowercase at both sides:

Character.toLowerCase(name1.charAt(i)) == Character.toLowerCase(name2.charAt(j))

There are also a methods you can use to verify if the letter is uppercase or lowercase:

Character.isUpperCase('P')
Character.isLowerCase('P') 
2 of 6
16

You can't actually do the job quite right with toLowerCase, either on a string or in a character. The problem is that there are variant glyphs in either upper or lower case, and depending on whether you uppercase or lowercase your glyphs may or may not be preserved. It's not even clear what you mean when you say that two variants of a lower-case glyph are compared ignoring case: are they or are they not the same? (Note that there are also mixed-case glyphs: \u01c5, \u01c8, \u01cb, \u01f2 or Dž, Lj, Nj, Dz, but any method suggested here will work on those as long as they should count as the same as their fully upper or full lower case variants.)

There is an additional problem with using Char: there are some 80 code points not representable with a single Char that are upper/lower case variants (40 of each), at least as detected by Java's code point upper/lower casing. You therefore need to get the code points and change the case on these.

But code points don't help with the variant glyphs.

Anyway, here's a complete list of the glyphs that are problematic due to variants, showing how they fare against 6 variant methods:

  1. Character toLowerCase
  2. Character toUpperCase
  3. String toLowerCase
  4. String toUpperCase
  5. String equalsIgnoreCase
  6. Character toLowerCase(toUpperCase) (or vice versa)

For these methods, S means that the variants are treated the same as each other, D means the variants are treated as different from each other.

Behavior     Unicode                             Glyphs
===========  ==================================  =========
1 2 3 4 5 6  Upper  Lower  Var Up Var Lo Vr Lo2  U L u l l2
- - - - - -  ------ ------ ------ ------ ------  - - - - -
D D D D S S  \u0049 \u0069 \u0130 \u0131         I i İ ı   
S D S D S S  \u004b \u006b \u212a                K k K     
D S D S S S  \u0053 \u0073        \u017f         S s   ſ   
D S D S S S  \u039c \u03bc        \u00b5         Μ μ   µ   
S D S D S S  \u00c5 \u00e5 \u212b                Å å Å     
D S D S S S  \u0399 \u03b9        \u0345 \u1fbe  Ι ι   ͅ ι 
D S D S S S  \u0392 \u03b2        \u03d0         Β β   ϐ   
D S D S S S  \u0395 \u03b5        \u03f5         Ε ε   ϵ   
D D D D S S  \u0398 \u03b8 \u03f4 \u03d1         Θ θ ϴ ϑ   
D S D S S S  \u039a \u03ba        \u03f0         Κ κ   ϰ   
D S D S S S  \u03a0 \u03c0        \u03d6         Π π   ϖ   
D S D S S S  \u03a1 \u03c1        \u03f1         Ρ ρ   ϱ   
D S D S S S  \u03a3 \u03c3        \u03c2         Σ σ   ς   
D S D S S S  \u03a6 \u03c6        \u03d5         Φ φ   ϕ   
S D S D S S  \u03a9 \u03c9 \u2126                Ω ω Ω     
D S D S S S  \u1e60 \u1e61        \u1e9b         Ṡ ṡ   ẛ   

Complicating this still further is that there is no way to get the Turkish I's right (i.e. the dotted versions are different than the undotted versions) unless you know you're in Turkish; none of these methods give correct behavior and cannot unless you know the locale (i.e. non-Turkish: i and I are the same ignoring case; Turkish, not).

Overall, using toUpperCase gives you the closest approximation, since you have only five uppercase variants (or four, not counting Turkish).

You can also try to specifically intercept those five troublesome cases and call toUpperCase(toLowerCase(c)) on them alone. If you choose your guards carefully (just toUpperCase if c < 0x130 || c > 0x212B, then work through the other alternatives) you can get only a ~20% speed penalty for characters in the low range (as compared to ~4x if you convert single characters to strings and equalsIgnoreCase them) and only about a 2x penalty if you have a lot in the danger zone. You still have the locale problem with dotted I, but otherwise you're in decent shape. Of course if you can use equalsIgnoreCase on a larger string, you're better off doing that.

Here is sample Scala code that does the job:

def elevateCase(c: Char): Char = {
  if (c < 0x130 || c > 0x212B) Character.toUpperCase(c)
  else if (c == 0x130 || c == 0x3F4 || c == 0x2126 || c >= 0x212A)
    Character.toUpperCase(Character.toLowerCase(c))
  else Character.toUpperCase(c)
}
🌐
W3Schools
w3schools.com › java › ref_string_equalsignorecase.asp
Java String equalsIgnoreCase() Method
Java Examples Java Videos Java Compiler Java Exercises Java Quiz Java Code Challenges Java Practice Problems Java Server Java Syllabus Java Study Plan Java Interview Q&A Java Certificate · ❮ String Methods · Compare strings to find out if they are equal, ignoring case differences: String myStr1 = "Hello"; String myStr2 = "HELLO"; String myStr3 = "Another String"; System.out.println(myStr1.equalsIgnoreCase(myStr2)); // true System.out.println(myStr1.equalsIgnoreCase(myStr3)); // false ·
Discussions

[Java] how to make object equals case-insensitive?
How are the sequence of characters (like "ACgt") represented in the object? If they're strings, then you should compare those rather than the objects themselves. Think of an object as a container which holds information about a real-life object. E.g., if the object has a field dna which has that sequence as a string, just compare this.dna and obj.dna. Make sure to cast the object to the appropriate type as well. Also, if your if statement is that simple, you could probably just return (condition) rather than using an entire if statement. More on reddit.com
🌐 r/learnprogramming
9
1
January 25, 2017
Is there a way to make .equalsIgnoreCase() compare characters instead of Strings?
You could use Character.toLowerCase(x) == Character.toLowerCase(y), you'd need to import the Character library too ofc More on reddit.com
🌐 r/learnjava
7
21
November 6, 2020
Java: String: equalsIgnoreCase vs switching everything to Upper/Lower Case - Stack Overflow
Two strings are considered equal ... are equal ignoring case. Two characters c1 and c2 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 java.lang.Charac... More on stackoverflow.com
🌐 stackoverflow.com
Performance of String.equalsIgnoreCase vs String.equals if I one of the strings is static.

This all sounds like premature optimization to me. User input is so slow that the differences here are trivial. My suggestion is to go for readability, and to me using .equalsIgnoreCase() conveys what you want to accomplish more clearly.

More on reddit.com
🌐 r/java
22
11
January 1, 2013
🌐
Scaler
scaler.com › home › topics › equalsignorecase() in java
equalsIgnoreCase() in Java - Scaler Topics
April 26, 2022 - The equalsIgnoreCase() method in Java compares the specified string with another string, ignoring lower and upper case differences. The method returns true if the strings are equal, and false if not.
🌐
Tutorialspoint
tutorialspoint.com › java › lang › string_equalsignorecase.htm
Java - String equalsIgnoreCase() Method
The java.lang.String.equalsIgnoreCase() ... 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....
🌐
LabEx
labex.io › tutorials › java-how-to-compare-chars-ignoring-case-467097
How to compare chars ignoring case | LabEx
Java provides multiple techniques to achieve this. graph TD A[Case-Insensitive Comparison] --> B{Comparison Type} B --> |Single Character| C[Convert Case] B --> |String| D[Use equalsIgnoreCase()] C --> E[Compare Converted Characters] D --> F[Compare Strings]
🌐
W3Resource
w3resource.com › java-tutorial › string › string_equalsignorecase.php
Java String: equalsIgnoreCase Method - w3resource
Applying the method Character.toLowerCase(char) to each character produces the same result ... Return Value: true if the argument is not null and it represents an equivalent String ignoring case; false otherwise.
🌐
Reddit
reddit.com › r/learnprogramming › [java] how to make object equals case-insensitive?
r/learnprogramming on Reddit: [Java] how to make object equals case-insensitive?
January 25, 2017 -

So I am writing a method that returns true if the argument obj is not null and is of the same type as this object such that both objects represent the identical sequence of characters in a case insensitive mode ("ACgt" is identical to "AcGt").

I have this so far, but as you may guess - the ".equalsIgnoreCase()" only works on strings. Any way to make objects case insensitive?

public boolean equals(Object obj)
{
	if(obj != null && obj.equalsIgnoreCase(this))
	{
		return true;
	}
	return false;
}
Find elsewhere
🌐
Reddit
reddit.com › r/learnjava › is there a way to make .equalsignorecase() compare characters instead of strings?
r/learnjava on Reddit: Is there a way to make .equalsIgnoreCase() compare characters instead of Strings?
November 6, 2020 -

I have my code written exactly as it would be if i was comparing Strings, but it wont work. alternatively, changing my character to a String would likely work if there is a way to do that.

Edit- I took a shower and realized that since characters are saved as unicode values, i could just compare them like you would an integer. Eg- if(char == 65)

🌐
Javatpoint
javatpoint.com › java-string-equalsignorecase
Java String equalsIgnoreCase() method - javatpoint
Java String equalsIgnoreCase() method with method signature and examples of concat, compare, touppercase, tolowercase, trim, length, equals, split, string equalsignorecase in java etc.
🌐
W3Schools
w3schools.com › java › ref_string_comparetoignorecase.asp
Java String compareToIgnoreCase() Method
String myStr1 = "HELLO"; String myStr2 = "hello"; System.out.println(myStr1.compareToIgnoreCase(myStr2)); ... The compareToIgnoreCase() method compares two strings lexicographically, ignoring lower case and upper case differences.
🌐
CodeGym
codegym.cc › java blog › strings in java › string equalsignorecase() method in java
String equalsIgnoreCase() Method in Java
February 13, 2025 - When you need to compare the contents of a string with another string ignoring case sensitivity. inputString1.equalsIgnoreCase(inputString2); Here the contents of both strings inputString1 and inputString2 are compared with each other. This method receives a string which is compared with another string calling the equalsIgnoreCase() method.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-string-equalsignorecase-method-with-examples
Java String equalsIgnoreCase() Method - GeeksforGeeks
December 23, 2024 - In Java, equalsIgnoreCase() method of the String class compares two strings irrespective of the case (lower or upper) of the string. This method returns a boolean value, true if the argument is not null and represents an equivalent String ignoring ...
🌐
Vultr Docs
docs.vultr.com › java › standard-library › java › lang › String › equalsIgnoreCase
Java String equalsIgnoreCase() - Compare Ignoring Case | Vultr Docs
December 18, 2024 - Java provides several methods for comparing strings to enhance flexibility and efficiency in handling text data. Among these, the equalsIgnoreCase() method stands out when you need to compare two strings without considering their case sensitivity.
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.lang.string.equalsignorecase
String.EqualsIgnoreCase(String) Method (Java.Lang) | Microsoft Learn
Two characters c1 and c2 are considered the same ignoring case if at least one of the following is true: <ul> <li> The two characters are the same (as compared by the == operator) <li> Calling Character.toLowerCase(Character.toUpperCase(char)) on each character produces the same result </ul> Note that this method does <em>not</em> take locale into account, and will result in unsatisfactory results for certain locales. The java.text.Collator class provides locale-sensitive comparison.
🌐
GeeksforGeeks
geeksforgeeks.org › equalsignorecase-in-java
equalsIgnoreCase() in Java - GeeksforGeeks
December 4, 2018 - This method returns true if the argument is not null and it represents an equivalent String ignoring case, else false. ... Input : str1 = "pAwAn"; str2 = "PAWan" str2.equalsIgnoreCase(str1); Output :true Input : str1 = "powAn"; str2 = "PAWan" ...
🌐
How to do in Java
howtodoinjava.com › home › string › java string equalsignorecase()
Java String equalsIgnoreCase() with Examples - HowToDoInJava
January 6, 2023 - The Java String.equalsIgnoreCase() ... equalsIgnoreCase(), two strings are considered equal if they are of the same length and corresponding characters in the two strings are equal, ignoring their cases....
🌐
Medium
medium.com › @AlexanderObregon › checking-if-two-words-are-the-same-in-java-without-case-sensitivity-e181a388dcfa
Checking if Two Words are the Same in Java Without Case Sensitivity
August 14, 2025 - This transformation is called case normalization. When you call equalsIgnoreCase, Java compares characters position by position and maps each pair to a common case during the check.
🌐
DEV Community
dev.to › satyam_gupta_0d1ff2152dcc › java-equalsignorecase-explained-your-guide-to-case-insensitive-string-comparison-37g1
Java equalsIgnoreCase() Explained: Your Guide to Case-Insensitive String Comparison - DEV Community
November 4, 2025 - Q2: Does equalsIgnoreCase() ignore other differences like spaces or accents? Nope. It only ignores case differences. "hello world" and "helloworld" are different. "resume" and "résumé" are also different.