그래서 하나의 String 객체와 하나의 정수를 허용하고 그 문자열을 정수로 반복하는 메소드를 작성해야합니다.메서드를 사용한 문자열 반복
예 : repeat ("ya", 3) "yayaya"를 표시해야합니다. 이 코드는 적어 두었지만 다른 하나는 인쇄합니다. 너 나 좀 도와 줄래?
public class Exercise{
public static void main(String[] args){
repeat("ya", 5);
}
public static void repeat(String str, int times){
for(int i = 0;i < times;i++){
System.out.println(str);
}
}
}
변경 System.out.print''에'System.out.println','후 당신의 고리). –
[Print a String 'X'Times (No Loop)] 가능한 복제본 (http://stackoverflow.com/questions/19455473/print-a-string-x-times-no-loop) – smac89