Add equalsIgnoreCase to the file (#27662)
The function equalsIgnoreCase() is also used for comparing the equality of 2 strings.
This commit is contained in:
committed by
The Coding Aviator
parent
9192e0c5da
commit
ef8c5e5bfa
@ -64,5 +64,17 @@ For example, the `java.util.Set` interface specifies that a `Set`'s `equals()` m
|
||||
|
||||
However, if a class does not override the default `equals()` implementation, the default implementation will apply, which simply uses the `==` operator to compare the two objects.
|
||||
|
||||
## The `.equalsIgnoreCase()` Method
|
||||
|
||||
This built-in function in java is used to compare the equality of 2 strings return true or false depending on the match but this function does not see if the characters are in upper case or in lower case.
|
||||
Example:
|
||||
|
||||
```java
|
||||
String s1="DEMO for Equality";
|
||||
String s2="Demo for equality";
|
||||
System.out.println(s1.equals(s2)); //false
|
||||
System.out.println(s1.equalsIgnoreCase(s2)); //true
|
||||
```
|
||||
|
||||
#### More Information:
|
||||
- [Oracle Java Docs : Equality Operators](https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.21)
|
||||
|
Reference in New Issue
Block a user