반응형
SMALL

언어 114

charAt, indexOf

public class CharAtVsIndexOfExample { public static void main(String[] args) { String str = "Hello, World!"; // charAt 메서드로 인덱스 7의 문자를 가져오기 char charAtIndex7 = str.charAt(7); // 'W' 출력 System.out.println("인덱스 7의 문자: " + charAtIndex7); // indexOf 메서드로 문자 'o'의 첫 번째 인덱스 찾기 int indexOfO = str.indexOf('o'); // 4 출력 System.out.println("'o'의 첫 번째 인덱스: " + indexOfO); // indexOf 메서드로 문자열 "World"의 시작 인덱스 ..

JAVA/JAVA Note 2023.08.16
반응형
LIST