Java String.equalsignorecase () method

Source: Internet
Author: User

Java string.equalsignorecase () method Usage example tutorial, comparing strings to another string, ignoring case factors.

The java.lang.String.equalsIgnoreCase () method compares a string to another string, ignoring the case factor. Two strings are considered equal when ignoring case, if they are two strings of the same length and the corresponding characters are equal ignoring casing

Statement

The following is a declaration of the Java.lang.String.equalsIgnoreCase () method

public boolean equalsignorecase (String anotherstring)
Parameters
    • anotherstring -This is a string comparison string pair

return value

This method returns true if the argument is not NULL, it is equivalent to a string that ignores case, otherwise returns false

Abnormal
    • NA

Instance

The following example shows the Java.lang.String.equalsIgnoreCase () method used

Package Com.yiibai;import java.lang.*;p ublic class Stringdemo {public  static void Main (string[] args) {      String s TR1 = "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);}          }

Let's compile and run the above program, which will produce the following results:

STR2 are equal to STR1 = Falsestr2 are equal to STR3 = True

Java String.equalsignorecase () method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.