> 其他 >
eclipse 输入一段话,看有几个单词 比如输入 what is your name? 输出 what,is,your,name
人气:360 ℃ 时间:2020-03-25 22:16:24
解答
import java.util.Scanner;
public class CCCC {
public static void main(String[] args) {
String input =null;
Scanner nn = new Scanner(System.in);
System.out.println("输入:");
String a = nn.nextLine().replace(' ',',');
System.out.println(a);
}
}
上面的随手写写,也写对呀……哪有.read()?是next()吗?是nextLine()!这个好用了能用 indexof 这个吗 那个方法我们没学过 谢谢了~~方法是不断学习的,你只用你学过的,以后不学了??public int indexOf(int ch, int fromIndex)返回在此字符串中第一次出现指定字符处的索引,从指定的索引开始搜索。 这个你看合适不??肯定不合适呀!问题是老师让用那个啊 。。。。我用这个不给分。。。。帮帮忙啦
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版