简单的问题:运行后的情况如下:
text:
2
4
2 text但我想要这个:
案文:2-4
2文本
System.out.println("text:");
for (int i = 0; i < tomb.length; i++) {
if (tomb[i] % 2 == 0) {
System.out.println("" + tomb[i]);
db++;
}
}
System.out.println(db + " text");发布于 2016-05-02 15:21:23
改变这个
System.out.println("" + tomb[i]);至
System.out.print("" + tomb[i]);编辑:实际上,你也必须改变这个
System.out.println("text:");至
System.out.print("text:");因为打印机将光标设置在下一行。
发布于 2016-05-02 15:21:55
在代码中处处使用System.out.print(),而不是每次在不同的行上打印System.out.println(); wich。
https://stackoverflow.com/questions/36985948
复制相似问题