Created
July 8, 2012 17:26
-
-
Save phl0w/3071917 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ProgrammingChallenge { | |
| public static void main(String... args) { | |
| System.out.println(stringTimes("Hi", 5)); | |
| } | |
| public static String stringTimes(String str, int n) { | |
| StringBuilder sb = new StringBuilder(); | |
| if (n <= 0) { | |
| System.err.println("n must be > 0"); | |
| } else { | |
| for (int i = 0; i < n; i++) { | |
| sb.append(str); | |
| } | |
| } | |
| return sb.toString(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment