Advertisement
jaVer404

level06.lesson08.task05

Apr 6th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. package com.javarush.test.level06.lesson08.task05;
  2.  
  3. /* Класс StringHelper
  4. Cделать класс StringHelper, у которого будут 2 статических метода:
  5. String multiply(String s, int count) – возвращает строку повторенную count раз.
  6. String multiply(String s) – возвращает строку повторенную 5 раз.
  7. Пример:
  8. Амиго -> АмигоАмигоАмигоАмигоАмиго
  9. */
  10.  
  11. public class StringHelper
  12. {
  13.     public static String multiply(String s)
  14.     {
  15.         String a = "";
  16.         String result = s;
  17.         for (int i = 0; i<5; i++) {
  18.             a=a+result;
  19.         }
  20.  
  21.         //Напишите тут ваш код
  22.         return a;
  23.     }
  24.  
  25.     public static String multiply(String s, int count)
  26.     {
  27.         String a ="";
  28.         String result = s;
  29.         //Напишите тут ваш код
  30.         for (int i=0; i<count; i++) {
  31.             a = a+result;
  32.         }
  33.         return a;
  34.     }
  35. /*
  36.     public static void main(String[] args)
  37.     {
  38.         System.out.println(multiply("Vita"));
  39.         System.out.println(multiply("Roma",4));
  40.     }
  41. */
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement