java基础学习:for循环,for循环案例
1.for循环:
2.
3.for循环案例
package com.itheima.loop; public class For2 { public static void main(String[] args) { for (int i = 0; i <=100 ; i++) { System.out.println(i); } int a=0; for (int i = 0; i <=100 ; i++) { a=a+i;//a +=i } System.out.println(a); System.out.println("---------------------------------------"); int b=0; for (int i = 0; i <=100 ; i+=2) { b=b+i;//a +=i }//计算出1-100之间的奇数合 System.out.println(b); } }