Curriculum
Course: Java Basic
Login

Curriculum

Java Basic

Java Home

0/1

Java Introduction

0/1

Java Get Started

0/1

Java Syntax

0/1

Java Comments

0/1

Java Type Casting

0/1

Java Operators

0/1

Java Booleans

0/1

Java Switch

0/1

Java Break / Continue

0/1

Java Errors and Exception

0/1
Text lesson

equalsIgnoreCase()

Example

Rephrase: “Compare strings while disregarding case differences to determine equality.”

String myStr1 = "Hello";
String myStr2 = "HELLO";
String myStr3 = "Another String";
System.out.println(myStr1.equalsIgnoreCase(myStr2)); // true
System.out.println(myStr1.equalsIgnoreCase(myStr3)); // false

Definition and Usage

The equalsIgnoreCase() method compares two strings, disregarding differences in upper and lower case.

This method returns true if the strings are equal and false if they are not.

Suggestion: Utilize the compareToIgnoreCase() method for lexicographically comparing two strings, while disregarding differences in case.

Syntax

public boolean equalsIgnoreCase(String anotherString)

Parameter Values

Parameter

Description

anotherString

A string that represents the other string for comparison.

Technical Details

Returns:

A boolean value:

 

•  True: If the strings are equal, regardless of case differences.

  •            false: if the strings are not equal