charAt()

Gyujin Cho·2022년 2월 1일
0

Java

목록 보기
1/7

char charAt(int index)

문자열(String)의 index위치에 있는 한 글자를 'char'타입으로 리턴한다.
public class gyujin {
	public static void main(String[] args) {
		String str = "Hello";
		System.out.println(str1.charAt(0)); // 첫글자(H)
        System.out.println(str.charAt(str.length()-1));// 마지막글자(o)
	}
}
profile
간단 명료하게

0개의 댓글