中文字幕一区二区人妻电影,亚洲av无码一区二区乱子伦as ,亚洲精品无码永久在线观看,亚洲成aⅴ人片久青草影院按摩,亚洲黑人巨大videos

Java regionMatches() 方法

Java String類Java String類


regionMatches() 方法用于檢測兩個字符串在一個區(qū)域內(nèi)是否相等。

語法

public boolean regionMatches(int toffset,
                             String other,
                             int ooffset,
                             int len)

或

public boolean regionMatches(boolean ignoreCase,
                             int toffset,
                             String other,
                             int ooffset,
                             int len)

參數(shù)

  • ignoreCase -- 如果為 true,則比較字符時忽略大小寫。

  • toffset -- 此字符串中子區(qū)域的起始偏移量。

  • other -- 字符串參數(shù)。

  • ooffset -- 字符串參數(shù)中子區(qū)域的起始偏移量。

  • len -- 要比較的字符數(shù)。

返回值

如果字符串的指定子區(qū)域匹配字符串參數(shù)的指定子區(qū)域,則返回 true;否則返回 false。是否完全匹配或考慮大小寫取決于 ignoreCase 參數(shù)。

實例

public class Test {
????public static void main(String args[]) {
????????String Str1 = new String("");
????????String Str2 = new String("json");
????????String Str3 = new String("JSON");

????????System.out.print("返回值 :" );
????????System.out.println(Str1.regionMatches(4, Str2, 0, 5));

????????System.out.print("返回值 :" );
????????System.out.println(Str1.regionMatches(4, Str3, 0, 5));

????????System.out.print("返回值 :" );
????????System.out.println(Str1.regionMatches(true, 4, Str3, 0, 5));
????}
}

以上程序執(zhí)行結果為:

返回值 :true
返回值 :false
返回值 :true

Java String類Java String類

其他擴展