使用扫描仪提示用户输入句子和字符串
import java.util.Scanner; /* 时代Java公众号 - nowjava.com 提 供 */ public class RemoveString { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String sentence; String text; System.out.print("Enter a sentence:"); sentence=scan.nextLine(); System.out.print("Enter a string:"); text=scan.nextLine(); // 来 自 时代Java公众号 System.out.print(sentence.replace(text, "")); scan.close(); } }