編集の要約なし
編集の要約なし
2行目: 2行目:
public boolean endsWith(String suffix)
public boolean endsWith(String suffix)


この文字列が、指定された接尾辞で終るかどうかを判定します。
指定文字列で終わるか調べます。equals メソッドが使われています。


  if (input.matches("ho[gbw]e")) {
  if (input.endsWith("ho")) {
     System.out.println("It matches!");
     System.out.println("It ends with 'ho' .");
  }
  }

2019年5月31日 (金) 09:45時点における版

(String).endsWith [1]
public boolean endsWith(String suffix)

指定文字列で終わるか調べます。equals メソッドが使われています。

if (input.endsWith("ho")) {
    System.out.println("It ends with 'ho' .");
}