public class Test03 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String str = scan.next();
char[] chars = str.toCharArray();
new Thread(new Runnable() {
@Override
public void run() {
for (int i = 0; i < chars.length - 1; i++) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
for (int j = 0; j <= i; j++) {
System.out.print(chars[j]);
}
System.out.println();
}
}
}).start();
}
}
输入字符串,每一秒打印多打印一个字符
最新推荐文章于 2022-10-31 11:35:06 发布