[Java] 프로그래머스 문자 반복 출력하기

박철현·2023년 3월 9일

프로그래머스

목록 보기
5/80

프로그래머스 문제풀이 문자 반복 출력하기

class Solution {
    public String solution(String my_string, int n) {
        StringBuilder sb = new StringBuilder();
        for(int i=0; i<my_string.length(); i++) {
            String tmp;
            tmp = my_string.substring(i,i+1);
            sb.append(tmp.repeat(n)); 
        }
        return sb.toString();
    }
}
profile
비슷한 어려움을 겪는 누군가에게 도움이 되길

0개의 댓글