Java String regionMatches(int toffset)Example
String class regionMatches(int toffset)method example
String class regionMatches(int toffset) method example. This example shows you how to use regionMatches(int toffset) method.This method Tests if two string regions are equal.
Here is the code:-
/**
* @(#) RegionMatches1string.java
*Program that Tests if two string regions are equal or not.
* @Version 02-May-2008
* @author Rose India Team
*/
public class RegionMatches1string
{
public static void main(String[] args)
{
String str1 = "Welcome to RoseIndia";
String str2 = "I works with RoseIndia";
/* Determine whether characters from index 11 to 19 in str1 match characters from index 13 to 21 in str2, Considering the case of the letters.*/
// regionMatches(int toffset, String other, int ooffset, int len)
boolean match1 = str1.regionMatches(11, str2, 13, 9);
System.out.println("str1[11 -19] == str2[13 - 21]:-" + match1);
}
} |
null
|