[Java] startsWith/endsWith

이지현·2023년 4월 11일
0
post-thumbnail

✔️ startsWith

  • 대상 문자열이 특정 문자 또는 문자열로 시작하는지 체크
public class etcPractice {
    public static void main(String[] args) {
        String str = "자바";
        System.out.println(str.startsWith("자")); // true
    }
}

✔️ endsWith

  • 대상 문자열이 특정 문자 또는 문자열로 끝나는지 체크
public class etcPractice {
    public static void main(String[] args) {
        String str = "자바";
        System.out.println(str.endsWith("바")); // true
    }
}
profile
2022.08 ~ 2023.09 / 현재 티스토리 이전 : https://jihyun-devstory.tistory.com/

0개의 댓글