Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Write a method named repl that accepts a String and a number of repetitions as parameters and returns the String concatenated that many times. For example, the call repl("hello", 3) returns "hellohellohello". If the number of repetitions is 0 or less, an empty string is returned.
- --------Code--------
- public String repl(String phrase, int num)
- {
- int i;
- String what = "";
- for(i = num-(num-1); i <= num; i++)
- {
- what += phrase;
- }
- return what;
- }
- -------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement