小编Geo*_*088的帖子

用Java慢慢打印文本

我刚刚开始使用Java编程,我正在尝试打印一串文本,一个接一个的字符,延迟.这是我到目前为止所拥有的:

public class SlowPrintHello {

    public static void main(String[] args) throws InterruptedException {
        // Get message, convert to char array
        String message = "Hello, World!";
        char[] chars = message.toCharArray();

        // Print a char from the array, then sleep for 1/10 second
        for (int i = 0; i == chars.length; i++) {
            System.out.print(chars[i]);
            Thread.sleep(100);
        }
        // Repeat for all chars
    }

}
Run Code Online (Sandbox Code Playgroud)

当我在Eclipse中运行时,控制台说没有输出就终止了.有谁知道发生了什么?

java

1
推荐指数
1
解决办法
3585
查看次数

标签 统计

java ×1