停止记录仪从新行打印
我是Java的新手,尝试使用Logger而不是System.out.print();
制作牛和公牛游戏,无法弄清楚如何从新线上打印每个数字,而是将其打印为一个数字。
示例:
logger.info(player + ", you lose. The number is : ");
for (int i = 0; i < random.length; i++) {
logger.info("{}", random[i]);
}
}
输出是:
17:54:27.668 [main] INFO com.bullsandcow.GameScreen - Viktors, you lose. The number is :
17:54:27.668 [main] INFO com.bullsandcow.GameScreen - 3
17:54:27.673 [main] INFO com.bullsandcow.GameScreen - 6
17:54:27.673 [main] INFO com.bullsandcow.GameScreen - 4
17:54:27.673 [main] INFO com.bullsandcow.GameScreen - 7
我想要的是将3647打印为一个数字。
I'm new to java, trying to use logger instead of System.out.print();
Making cows and bulls game and can't figure out how to make logger printing each digit from new line and instead print it as one number.
Example :
logger.info(player + ", you lose. The number is : ");
for (int i = 0; i < random.length; i++) {
logger.info("{}", random[i]);
}
}
output is :
17:54:27.668 [main] INFO com.bullsandcow.GameScreen - Viktors, you lose. The number is :
17:54:27.668 [main] INFO com.bullsandcow.GameScreen - 3
17:54:27.673 [main] INFO com.bullsandcow.GameScreen - 6
17:54:27.673 [main] INFO com.bullsandcow.GameScreen - 4
17:54:27.673 [main] INFO com.bullsandcow.GameScreen - 7
What I want is to print 3647 as one number.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设
随机
是int [],您需要将所有元素组合到字符串中。Assuming
random
is int[], what you need is to combine all element into a String.我不确定您想要什么,但是如果您只需要同一行中的随机数,则可以尝试:
i'm not sure what you want, but if you just need the random number in the same line, you can try: