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
🌐
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 · ❮ 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 ·
🌐
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.
Discussions

java - How to compare character ignoring case in primitive types - Stack Overflow
You can't actually do the job quite ... 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 ... More on stackoverflow.com
🌐 stackoverflow.com
[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
java - Ignoring uppercase and lowercase on char when comparing - Stack Overflow
The goal of this is to get a sentence from the user and determine how many of each vowel shows up.The majority of this is done except I am not sure how to ignore uppercase and lowercase letters but... More on stackoverflow.com
🌐 stackoverflow.com
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
🌐
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.
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)
}
🌐
Scaler
scaler.com › home › topics › equalsignorecase() in java
equalsIgnoreCase() in Java - Scaler Topics
April 26, 2022 - regionMatches(true, 0, anotherString, 0, value.length) : Here, the first parameter ignoreCase is set to true to ignore the case differences. After that, the corresponding characters from each string are taken and compared.
🌐
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....
🌐
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.
Find elsewhere
🌐
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]
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-string-equalsignorecase-method-with-examples
Java String equalsIgnoreCase() Method - GeeksforGeeks
December 23, 2024 - public class Geeks { public static ... to be compared. Return Value: A boolean value that is true if the argument is not null and it represents an equivalent String ignoring case, else false....
🌐
CodeGym
codegym.cc › java blog › strings in java › string equalsignorecase() method in java
String equalsIgnoreCase() Method in Java
February 13, 2025 - I am A string"; String comparisonString2 = "heLLo! i AM a STRING"; String comparisonString3 = "Hey there, here's another string to compare the first two."; System.out.println("Comparison Results"); // see if first 2 comparison strings are equal boolean result1 = comparisonString2.equalsIgnoreCase(comparisonString1); System.out.println("comparisonString2 is equal to comparisonString1 = " + result1); // check if second and third strings match when case ignored boolean result2 = comparisonString2.equalsIgnoreCase(comparisonString3); System.out.println("comparisonString2 is equal to comparisonString3 = " + result2); // check if first and third strings match boolean result3 = comparisonString3.equalsIgnoreCase(comparisonString1); System.out.println("comparisonString3 is equal to comparisonString1 = " + result3); } }
🌐
BeginnersBook
beginnersbook.com › 2013 › 12 › java-string-equals-and-equalsignorecase-methods-example
Java String equals() and equalsIgnoreCase() Methods example
September 11, 2022 - The method equalsIgnoreCase() ignores the case while comparing two strings. In the following example we compared the string “Apple” with the string “APPLE” and it returned true. public class JavaExample{ public static void main(String args[]){ String str1= new String("Apple"); String ...
🌐
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;
}
🌐
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....
🌐
TechVidvan
techvidvan.com › tutorials › java-string-equalsignorecase-method
Java String equalsIgnoreCase() Method - TechVidvan
February 26, 2024 - Comparing str1, str2 and str3 with the equaleIgnoreCase() method returns true as they read the same word after ignoring the case of the individual letters. The fourth string is entirely different from the other three strings as it lacks a few characters; hence, the use of equalsIgnoreCase on str4 and any of the three other strings results in a false.
🌐
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" ...
🌐
Vultr Docs
docs.vultr.com › java › standard-library › java › lang › String › equalsIgnoreCase
Java String equalsIgnoreCase() - Compare Ignoring Case | Vultr Docs
December 18, 2024 - Explore various examples where ... one contains upper case letters and the other lower case. Use the equalsIgnoreCase() method to compare these two strings....
🌐
Programiz
programiz.com › java-programming › library › string › equalsignorecase
Java String equalsIgnoreCase()
str1 and str2 are equal if you do not consider case differences. Hence, str1.equalsIgnoreCase(str2) returns true. str1 and str3 are not equal. Hence, str1.equalsIgnoreCase(str3) and str3.equalsIgnoreCase(str1) returns false. class Main { public static void main(String[] args) { String str1 ...
🌐
Delft Stack
delftstack.com › home › howto › java › char ignore case java
Character Ignore Case in Java | Delft Stack
October 12, 2023 - It also shows that both strings are not equal by comparing the characters. See output: ... The isLowerCase will ignore all uppercase characters in the string, and the isUpperCase will ignore all the lower case characters in the string.