How To Check Whether Two Strings Are The Same Using The equals() and equalsIgnoreCase() Method
Coding River
How To Check Whether Two Strings Are The Same Using The equals() and equalsIgnoreCase() Method
In this video, we will look at the equals() method and the equalsIgnoreCase() method. As you might have guessed these methods are used to check whether two Strings are equal. On one hand the equals() method considers the case sensitivity of the characters of both Strings being compared whereas on the other hand the equalsIgnoreCase() method considers the lowercase characters to be the same as the uppercase characters.
We have to note that these methods return true or false values. Let’s take an example to see how these methods behave
String str1 = “Programming”; String str2 = “PROGRAMMING”;
Let me write the statements to call the methods
System.out.println(str1.equals(str2)); System.out.println(str1.equalsIgnoreCase(str2));
When we run this program the result in the console will be: False True Because of the way each method apprehends case sensitivity.
I hope this video has been informative and please don’t forget to support this channel by liking this video and also by subscribing to this channel. Let’s meet in the next video. Cheers !!!!!
#codingriver #java #programming ... https://www.youtube.com/watch?v=VYWUvl_TAPc
9244130 Bytes