【发布时间】:2014-02-11 09:44:39
【问题描述】:
我有一系列问题被要求创建一副闪存卡。到目前为止,只要问题没有空格,我就可以收集问题和答案。如果问题确实有空格,则跳过答案,但是如果答案有空格,则没有问题。这是我的代码的 sn-p:
System.out.println("数字" + (cards + 1) + "?"); 问题 = in.next(); System.out.println("数字" + (cards + 1) + "?"); 答案 = in.next();这是一个问题和答案中带有空格的结果输出:
What is the question for number 1?
This is a question
What is the answer for number 1?
What is the question for number 2?
x
What is the answer for number 2?
This is an answer
What is the question for number 3?
X
【问题讨论】:
-
在
next之后使用Line。
标签: java string java.util.scanner