互联网技术 · 2024年2月28日

Java控制台输出百分比示例代码

System.out.print(“b”) 会在控制台下往回删掉一个字符,如果你想回删多个字符就打印多个 “b”

这个代码也可以参考一下:

public static void main(String[] args) throws Exception {

System.out.print(“Progress:”);

for (int i = 1; i <= 100; i++) {

System.out.print(i + “%”);

Thread.sleep(100);

for (int j = 0; j <= String.valueOf(i).length(); j++) {

System.out.print(“b”);

}

}

System.out.println();

}

OpenMagic API

Need more than content? Move into the product flow.

If you are here for model access, pricing, developer docs, or the future API console, the dedicated product path now lives on api.openmagic.ai.

登录免费注册