写一段计算1-20的java代码
时间: 2023-02-20 18:53:04 浏览: 75
public class CalcSum {
public static void main(String[] args) {
int sum = 0;
for (int i = 1; i <= 20; i++) {
sum += i;
}
System.out.println("The sum of 1-20 is: " + sum);
}
}
阅读全文