- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java String equalsIgnoreCase() method example.
The equalsIgnoreCase() method of the String class compares this String to another String, ignoring case considerations. Two strings are considered equal ignoring case if they are of the same length and corresponding characters in the two strings are the equal ignoring case.
Example
import java.lang.*; public class StringDemo { public static void main(String[] args) { String str1 = "sachin tendulkar"; String str2 = "amrood admin"; String str3 = "AMROOD ADMIN"; //Checking for equality with case ignored boolean retval1 = str2.equalsIgnoreCase(str1); boolean retval2 = str2.equalsIgnoreCase(str3); //Prints the return value System.out.println("str2 is equal to str1 = " + retval1); System.out.println("str2 is equal to str3 = " + retval2); } }
Output
str2 is equal to str1 = false str2 is equal to str3 = true
- Related Articles
- Java String compareTo() Method example.
- Java String substring() Method example.
- Java String endsWith() method example.
- Java String equals() method example.
- Java String format() method example.
- Java String getBytes() method example.
- Java String getChars() method example.
- Java String indexOf() method example.
- Java String intern() method example.
- Java String isEmpty() method example.
- Java String lastIndexOf() method example.
- Java String length() method example.
- Java String replace() method example.
- Java String split() method example.
- Java String startsWith() method example.

Advertisements