【发布时间】:2015-03-17 23:51:08
【问题描述】:
我想创建一个小程序,我可以在其中使用扫描仪输入字符串并替换字符。例如,字符串中的每个“a”都应替换为“4”。
我有这个源代码:
Scanner s = new Scanner(System.in);
String string = s.nextLine();
System.out.println("Your old text:" + original_string);
string.replace("i", "1");
string.replace("a", "4");
System.out.println("Your new super awesome text: " + string);
例如,如果我输入“ia”,它应该返回“14”。不幸的是,这不会发生。
【问题讨论】: