반응형 끝나는 (1) 썸네일형 리스트형 자바 - 문자열이 특정 문자열로 끝나는지 확인 방법 (endsWith() 메소드) 어떠한 문자열이 특정 문자열로 끝나는지 확인하는 String 클래스의 endsWith() 메소드가 존재한다.예를 들어, endsWith() 메소드를 활용해 A라는 문자열이 ".pdf"로 끝나는지 확인이 가능하다. public class Example { public static void main(String[] args) { String str = "www.naver.com"; System.out.println(str.endsWith(".com")); // true }}"www.naver.com"라는 문자열이 ".com"으로 끝나는지 endsWith() 메소드로 확인하니 true가 반환되었다. endsWith() 메소드 사용 시 주의 점은 문자열 비교 시 대소문자를 .. 이전 1 다음