java for循环

public class forxunhuan {
    public static void main(String[] args){
        for( int a=10;a<14;a=a+1){//前面是初始值,中间是要达到的条件,后面是循环条件
            System.out.println("value of a:"+a);
        }
        String [] names={"lo","ol","sf"};
        for (String name:names){//和python的for一样,遍历
            System.out.println(name);
        }
        int [] numbers={1,2,3,4,6,5,9,7,8,7,9};
        for (int c:numbers){
            if (c==6){//循环到6的时候跳出循环
                break;
            }
            System.out.println(c);
        }
    }
}

 运行结果

 

原文地址:https://www.cnblogs.com/lly-lcf/p/13359350.html