자바 문자열중 문자 뽑기 .charAt() 사용법 및 간단한 예시 코드 - 개발새발 작성 일기

개발새발자·2023년 10월 29일
1

자바 개념

목록 보기
11/15

.charAt()

  • String으로 저장된 문자열 중에서 한글자만 선택해서 char 타입으로 변환해주는 역할


간단한 예시 코드

public class SampleCharAt {
    public static void main(String[] args) {
        String str = "Hello";
        System.out.println(str.charAt(0)); // H
        System.out.println(str.charAt(1)); // e
        System.out.println(str.charAt(2)); // l

    }
}
profile
바삭하고 촉촉한 쿠키로 살자

0개의 댓글