class Solution {
public int solution(String my_string, String is_prefix) {
if(my_string.startsWith(is_prefix)){
return 1;
}else{
return 0;
}
}
}
startsWith 메서드는 주어진 문자열이 다른 문자열로 시작하는 여부를 확인하는 메서드
boolean startsWith(String prefix)
예시)
String str1 = "Hello, world!";
boolean startsWithHello = str1.startsWith("Hello"); // true
boolean startsWithWorld = str1.startsWith("world!"); // false
String str2 = "abcdefg";
boolean startsWithABC = str2.startsWith("ABC"); // false
boolean startsWithA = str2.startsWith("a"); // true