| 方法 | 描述 |
|---|---|
| boolean regionMatches(int toffset, String other, int ooffset, int len) | 判斷從 toffset 開始長度為 len 的子字串,是否與 other 從 ooffset開始長度為 len 的子字串相同 |
| boolean regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len) | 判斷從 toffset 開始長度為 len 的子字串,是否與 other 從 ooffset開始長度為 len 的子字串相同, ignoreCase 提供是否要忽略文大小寫字母 |
舉例如下
class RegionmatchesDemo {
public static void main(String[] args) {
String a = "Imagination is more important than knowledge.";
String b = "He who has hope has everything.";
String c = "台上一分鐘,台下十年功。";
String d = "Experience is the extract of suffering. ";
String e = "吃的苦中苦,方為人上人";
System.out.println(a.regionMatches(12, d, 11, 2));
System.out.println(b.regionMatches(true, 0, d, 15, 2));
System.out.println(c.regionMatches(3, e, 0, 2));
}
}
/* 《程式語言教學誌》的範例程式
http://pydoing.blogspot.com/
檔名:RegionmatchesDemo.java
功能:示範物件導向的基本觀念
作者:張凱慶
時間:西元 2010 年 10 月 */編譯後執行,結果如下

| 中英文術語對照 | |
|---|---|
| 類別 | class |
| 方法 | method |
| 字串 | string |
參考資料
http://download.oracle.com/javase/tutorial/java/data/strings.html
http://download.oracle.com/javase/tutorial/java/data/converting.html
http://download.oracle.com/javase/tutorial/java/data/manipstrings.html
http://download.oracle.com/javase/tutorial/java/data/comparestrings.html
http://download.oracle.com/javase/7/docs/api/java/lang/String.html
http://download.oracle.com/javase/tutorial/java/data/strings.html
http://download.oracle.com/javase/tutorial/java/data/converting.html
http://download.oracle.com/javase/tutorial/java/data/manipstrings.html
http://download.oracle.com/javase/tutorial/java/data/comparestrings.html
http://download.oracle.com/javase/7/docs/api/java/lang/String.html
沒有留言:
張貼留言