java 問題(print user input)

2009-02-14 5:22 am
如果想將user input的一行字 分開一行行print出來, while loop要怎樣寫呢?

例如user input是 my name is paul
要print出
my
name
is
paul

THANKS=]

回答 (1)

2009-02-14 9:22 am
✔ 最佳答案
Java has a class for doing exactly what you'd like to do.
If you need more information, see 參考資料 or PM me.
Here's an example:
import java.util.StringTokenizer;
....
StringTokenizer st = new StringTokenizer("my name is paul");
while (st.hasMoreTokens()) {
System.out.println(st.nextToken());
}


收錄日期: 2021-04-13 16:26:18
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20090213000051KK01645

檢視 Wayback Machine 備份