bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java String regionMatches() Method

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind Java String regionMatches() Method?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___ myStr1 = "Hello, World!";
3Order

Put the learning moves in the order that makes the concept easiest to apply.

The regionMatches() method compares regions in two different strings to check if they are equal.
Definition and Usage
Java String regionMatches() Method

❮ String Methods

Example

String myStr1 = "Hello, World!";
String myStr2 = "New World";
System.out.println(myStr1.regionMatches(7, myStr2, 4, 5));
System.out.println(myStr1.regionMatches(0, myStr2, 0, 5));

Definition and Usage

The regionMatches() method compares regions in two different strings to check if they are equal.

One of the following

public boolean regionMatches(boolean
ignoreCase , int
offset , String
other , int
otherOffset , int
length )
public boolean regionMatches(int
offset , String
other , int
otherOffset , int
length )

Parameter Values

ParameterDescription
ignoreCaseOptional. When true the comparison between regions will be case-insensitive. Defaults to false.
offsetRequired. The position in the string where the region starts.
otherRequired. The string with the other region that is being compared.
otherOffsetRequired. The position in the other string where the region starts.
lengthRequired. The size of the regions being compared.

Technical Details

Returns:true if the two regions are equal, false otherwise.
Java version:Any

Previous

Java String offsetByCodePoints() Method

Next

Java String replace() Method