Java Instance-test for equality of two string regions

Source: Internet
Author: User

 Packagestring; Public classRegionmatch { Public Static voidMain (string[] args) {/*** Compare the area of a string for equality*/String str1= "ABCDEFGE"; String str2= "DEFGE"; BooleanMatch1 =str1.regionmatches (4, STR2, 1, 3);//The first parameter represents the string starting from a few characters, the second argument to compare, the third argument to compare where the string starts, and the fourth parameter to compare the area        BooleanMatch2=str1.regionmatches (true, 4, STR2, 1, 3);//true indicates case insensitiveSystem.out.println (MATCH1);    System.out.println (MATCH2); }}

Output results

Java Instance-test for equality of two string regions

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.