In this section, you will learn how to compare two strings ignoring case sensitiveness Java provides the method that ignores cases, it only compare the character's sequence. The compareToIgnoreCase() method compares two strings and ignores its cases. This method returns an integer type value like: a negative integer, a positive or zero.
Description of program:
The following program compares two strings and ignore these cases but it compares the sequence of characters in the given string. In this program, three string types data have been used that have to be compared. Here the CharComp() method is applied for comparing strings. The compareToIgnoreCase() method compares strings and shows the given message.
Description of code:
This method is used to compare two strings with ignored cases. It takes following arguments:
str: This is the string that have to be compared.
Here is the code of program:
Output of program:
Character comparation to ignore case example!
String1 = Vinod
String2 = Vinod
String2 = vinod
String1 and String2 are equal!
String1 and String3 are equal!
String2 and String3 are equal!
Liked it! Share this Tutorial
Ask Questions? Discuss: Character Cases Ignoring case sensitiveness in java
Post your Comment