You are here: Home / Topics / regionMatches() method example in Java

regionMatches() method example in Java

Filed under: Java

// Program to explain the following String function :
// boolean regionMatches( int startIndex,
// String str2, int str2StartIndex, int numChars )

class  MregionMatches1 
{
public static void main(String args[ ])
{
 boolean b,b1;
 String s1 = new String("Java Programming Examples.");
 String s2 = new String("Programming");

 b = s1.regionMatches(5, s2, 0, 8);

 //  For ignore case.
 b1 = s1.regionMatches(true, 5, s2, 0, 8);

 System.out.print(" Result of Region Match : " + b);
 System.out.print(" Result of Region Match for ignore case : " + b1);
}
}


Output:

Result of Region Match : true
Result of Region Match for ignore case : true

Categories