/** * Created by xabcd on 2019/2/11. */ public class TestJava4_4 {public static void main(String[]args) { int sum = 0; for(int i=1;i<=5;i++) { sum = sum + i; System.out.println("i=" + i + ", sum =" + sum); } //i是局部变量 } } i=1, sum =1 i=2, sum =3 i=3, sum =6 i=4, sum =10 i=5, sum =15