编写一个JAVA程序 输入一个字符串 统计有多少个单词 单词用空格隔开

  • Post author:
  • Post category:java


public class 统计单词 {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		String[] split = str.split(" ");
		for (String string : split) {
			System.out.println(string);
		}
	}
}



版权声明:本文为San6653原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。