Advertisement
veronikaaa86

03. Substring

Jul 5th, 2023
901
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. package stringProcessing;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P03Substring {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         String toRemove = scanner.nextLine();
  10.         String text = scanner.nextLine();
  11.  
  12.         int index = text.indexOf(toRemove);
  13.         while (index != -1) {
  14.             text = text.replace(toRemove, "");
  15.  
  16.             index = text.indexOf(toRemove);
  17.         }
  18.  
  19.         System.out.println(text);
  20.     }
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement