Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package removestring;
- import java.util.Scanner;
- public class Removestring {
- static Scanner scanner = new Scanner(System.in);
- public static void main(String[] args) {
- System.out.println("Input Sentence: ");
- String input = scanner.nextLine();
- System.out.println("Input word to be removed: ");
- String section = scanner.nextLine();
- if(!(input.indexOf(section) == -1)){
- System.out.println(input.substring(0, input.indexOf(section)) + input.substring(input.indexOf(section) + section.length()));
- } else {
- System.out.println("Word not found");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement