流程控制

  1. 带标签的continue语句(goto)

    //输出101-150之间的所有质数
    outer: for (int i = 101; i < 150; i++) {
        for (int j = 2; j < i/ 2; j+=2){
            if (i % j == 0){
                continue outer;
            }
        }
        System.out.println(i);
    }
    

    break同理。

Copyright © rootwhois.cn 2021-2022 all right reserved,powered by GitbookFile Modify: 2023-03-05 10:55:52

results matching ""

    No results matching ""