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
| Parameter | Description |
|---|---|
| ignoreCase | Optional. When true the comparison between regions will be case-insensitive. Defaults to false. |
| offset | Required. The position in the string where the region starts. |
| other | Required. The string with the other region that is being compared. |
| otherOffset | Required. The position in the other string where the region starts. |
| length | Required. The size of the regions being compared. |
Technical Details
| Returns: | true if the two regions are equal, false otherwise. |
|---|---|
| Java version: | Any |