[백준] 10809 알파벳 찾기 JAVA

최희정·2022년 9월 6일
0

백준 [문자열]

목록 보기
1/2

단순히 String 클래스의 indexOf() 메서드의 사용법에 대해서 묻는 문제다.
indexOf()는 특정 문자의 위치를 반환하며, 존재하지 않을 경우 -1을 반환하는 메서드이다.

import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        
        String word = scan.next();
        for (char c = 'a' ; c <= 'z' ; c++)
            System.out.print(word.indexOf(c) + " ");
    }
}
profile
차근차근 일상을 기록하는 컴공생 👩🏻‍💻

0개의 댓글