by Dinesh Thakur Category: array

The String class includes several methods that compare strings or substrings within strings. To perform a comparison that ignores case differences, use equalsIgnoreCase(). This method considers lowercase and upper case characters as same while comparing strings. That is, it considers A-Z to be the same as a-z.

Syntax:

boolean equalsIgnoreCase(String str)

 

Here, str is the String object being compared with the invoking String object. It returns true if the strings contain the same characters in the same order, and false otherwise.

import java.io.*;

class StringComparison
{
            public static void main(String args[]) throws IOException
            {
                        BufferedReader dd=new BufferedReader(new InputStreamReader(System.in));
                        String ww;
                        System.out.println("Enter Few Strings or Enter stop to Exit ");
                        do
                        {
                                    ww=dd.readLine();     
                        }while(!ww.equalsIgnoreCase("stop"));
            }
}

String Comparison in Java Example



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles