gpt4 book ai didi

Java 格式化

转载 作者:行者123 更新时间:2023-12-02 04:21:40 27 4
gpt4 key购买 nike

Scanner scan = new Scanner(System.in);
System.out.println("Enter three positive integers seperated by spaces, then press enter: ");
int a = scan.nextInt();
int b = scan.nextInt();
int c = scan.nextInt();

如何才能使当用户输入数字时它显示在与问题相同的行而不是下面?

最佳答案

使用System.out.print()而不是System.out.println()

阅读每个的 javadoc。 println(String) “行为就像调用 print(String) 然后调用 println()”,因此您应该只使用 print(String) 如果您不需要新行。

关于Java 格式化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32700762/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com