「Java入門」startsWith/endsWithで文字列の始まり/終わりを判定する
1.文字列の先頭を判定する
String cft= "welcome japan";
if (strA.startsWith("wel")){
System.out.println("あり");
}else {
System.out.println("なし");
}
2.文字列の末尾を判定する
String cft= "welcome japan";
if (strA.endsWith("japan")){
System.out.println("あり");
}else {
System.out.println("なし");
}