desislava_topuzakova

02. Repeat Strings

Mar 27th, 2022
967
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. package TextProcessing;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class RepeatStrings_02 {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         String input = scanner.nextLine(); //"hi abc add"
  9.         String[] words = input.split(" "); //["hi", "abc", "add"]
  10.  
  11.         for (String word : words) {
  12.             int n = word.length();
  13.             System.out.print(word.repeat(n));
  14.         }
  15.  
  16.     }
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment