域名預(yù)訂/競(jìng)價(jià),好“米”不錯(cuò)過
System.out.print("\b") 會(huì)在控制臺(tái)下往回刪掉一個(gè)字符,如果你想回刪多個(gè)字符就打印多個(gè) "\b"
這個(gè)代碼也可以參考一下:
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();
}
申請(qǐng)創(chuàng)業(yè)報(bào)道,分享創(chuàng)業(yè)好點(diǎn)子。點(diǎn)擊此處,共同探討創(chuàng)業(yè)新機(jī)遇!