import java.util.Scanner;
public class WordLines {
public static void main(String [] args) {
Scanner sca = new Scanner(System.in);
System.out.println("Enter a sentence");
String s = sca.nextLine();
int count = 0;
for(int j=0; j<s.length(); j++)
System.out.println(s.charAt(j));
}
}
我正在尝试编写一个程序,该程序从用户输入中读取特定行,然后一次只显示一个单词从句子到新行。
For example
Input: The hill is very-steep!!
It would print out
The
hill
is
very-steep!!
So far I have done this much!!