(数列求和)编写程序,显示1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 的结果。
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package dome1_6;
/**
*
* @author Administrator
*/
public class Dome1_6 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int sum = 0;
for(int i = 1;i < 10;i ++){
sum += i;
}
System.out.println(sum);
}
}