Java String.endswith () method

Source: Internet
Author: User

Java String. EndsWith () method Usage Example tutorial, the method returns a true if the argument represents a sequence of characters represented by the suffix of the character sequence, otherwise returns false

Describe

java.lang.String. EndsWith The () method returns the test whether the string ends with the specified suffix Sffix

Statement

The following is the declaration java.lang.String. EndsWith () method

EndsWith (String suffix)
Parameters
    • suffix --this is the suffix.

return value

The method returns a true if the argument represents a sequence of characters that is the suffix of the character sequence represented by the object, otherwise false is returned.

Abnormal
    • NA

Instance

The following example shows the java.lang.String used. EndsWith () method.

Package Com.yiibai;import java.lang.*;p ublic class Stringdemo {public  static void Main (string[] args) {      String s TR = "www.yiibai.com";    System.out.println (str);    The end string to is checked    string endstr1 = ". com";    String endstr2 = ". org";    Checks that string str ends with given substring    boolean retval1 = str.endsWith(ENDSTR1);    Boolean retval2 = str.endsWith(ENDSTR2);    Prints true if the string ends with given substring    System.out.println ("ends with" + Endstr1 + "?" + Retval1); C13/>system.out.println ("ends with" + Endstr2 + "?" + Retval2);}  }

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

Www.yiibai.comends with. com? Trueends with. org? False

Java String.endswith () 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.