Sid :
i am a student and was doing some practice with strings in java,i came across regionMatches() method, i came to know that it is case sensitive, therefore on running the following program where i am comparing a part of str1 with str2,
String Str1 = "my dog's name is bruno";
String Str2 = "bruno";
String Str3 = "BRUNO";
System.out.println(Str1.regionMatches(17, Str2, 0, 5));
this gives the output as true, but as this is case sensitive , therefore, upon executing the following one, where a part of str1 is compared with str3,
String Str1 = "my dog's name is bruno";
String Str2 = "bruno";
String Str3 = "BRUNO";
System.out.println(Str1.regionMatches(17, Str3, 0, 5));
it gives output as false. i want to know if there's any way by which it can ignore the case?
Michael :
There is another signature of the same method which takes a boolean as the first argument indicating whether case should be ignored.
public boolean regionMatches(boolean ignoreCase, //<<<
int toffset,
String other,
int ooffset,
int len)
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=349202&siteId=1