我有简单的代码和三个不同的输出。如何强制IDEA和/或Gradle处理回车?
for(int i = 0; i < 5; i++) {
System.out.format("%2d\r", i);
Thread.sleep(1000);
}
据我所知,您想打印与平台无关的换行符。在这种情况下,请查看this article,它描述了format
和printf
。更具体地说:
Here is a basic example:
int i = 461012;
System.out.format("The value of i is: %d%n", i);
The %d specifies that the single variable is a decimal integer. The %n is a platform-independent newline character.