Java Onlines
Java Sandbox
Java Benchmark
Math
String
Python Sandbox
PHP Sandbox
Java Sandbox
Java Benchmark
Math
String
Python Sandbox
PHP Sandbox
Online Java regionMatches() function
regionMatches
- Tests if two string regions are equal
Title
public class Main { public static void main(String[] args) { //String str1 = "Red Green Orange Yellow"; //String str2 = "Yellow Orange Green Red"; String str1 = "Shanghai Houston Colorado Alexandria"; String str2 = "Alexandria Colorado Houston Shanghai"; // Determine whether characters 0 through 7 in str1 // match characters 28 through 35 in str2. boolean match1 = str1.regionMatches(0, str2, 28, 8); // Determine whether characters 9 through 15 in str1 // match characters 9 through 15 in str2. boolean match2 = str1.regionMatches(9, str2, 9, 8); System.out.println(); // Display the results of the regionMatches method calls. System.out.println("str1[0 - 7] == str2[28 - 35]? " + match1); System.out.println("str1[9 - 15] == str2[9 - 15]? " + match2); System.out.println(); } }
Run on Java version:
14
14.0.1
14
13
13.0.2
13.0.1
13
12
12.0.2
12.0.1
12
11
11.0.7
11.0.6
11.0.5
11.0.4
11.0.3
11.0.2
11.0.1
11
10
10.0.2
10.0.1
10
9
9.0.4
9.0.1
9
8
8
7
7
6
6
Execute Code
String Functions
charAt
codePointAt
codePointBefore
codePointCount
compareTo
compareToIgnoreCase
concat
contains
contentEquals
copyValueOf
endsWith
equals
equalsIgnoreCase
format
getBytes
getChars
hashCode
indexOf
intern
isEmpty
lastIndexOf
length
matches
offsetByCodePoints
regionMatches
replace
replaceAll
replaceFirst
split
startsWith
subSequence
substring
toCharArray
toLowerCase
toString
toUpperCase
trim
valueOf