regionMatchesメソッド
特定範囲の文字列を比較する – regionMatchesメソッド- public boolean regionMatches([boolean ignore,]
 - int toff, String other, int ooff, int len)
 - ignore:大文字小文字を無視するか
 - toff:比較される文字列の開始位置
 - other:比較する文字列
 - ooff:比較する文字列の開始位置
 - len:比較する文字数
 
regionMatchesメソッドは、文字列同士を指定された文字範囲に限定して比較します。比較開始位置をそれぞれ引数toff/ooffで、比較する文字数を引数lenで指定します。
  equalsメソッドと同じく、対象の文字範囲が等しい場合にはtrue、さもなければfalseを返します。
StrRegion.java
package com.example.mynavi.string;
public class StrRegion {
  public static void main(String[] args) {
    String str1 = "Hello World!";
    String str2 = "Hi world!";
    System.out.println(str1.regionMatches(false, 6, str2, 3, 5));
	// 結果:false
    System.out.println(str1.regionMatches(true, 6, str2, 3, 5));
	// 結果:true
  }
}
関連ページ
equalsメソッド






