【Thinking in Java, 4e】控制流程执行

p46~p75:

【迭代】

1、Java不允许将数字作为布尔值用。

1、有点意思的小程序WhileTest。

public class WhileTest {
    static boolean condition() {
        boolean result = Math.random() < 0.99;
        System.out.println(result + ", ");
        return result;
    }
    public static void main(String[] args) {
        while (condition()) {
            System.out.println("Inside 'while'");
        }
        System.out.println("Exited 'while'");
    }
}

【Foreach语法】

1、对细节关注过多就很容易丢掉主干、本质。

2、可读性就是:说明你在努力做什么,而不是给出你正在如何做的细节。

原文地址:https://www.cnblogs.com/xkxf/p/6582269.html