编写1加到100的java代码
时间: 2024-05-09 19:19:06 浏览: 29
java代码-使用java编写1+14+19+116+....+1100的源代码
```java
public class SumOfNumbers {
public static void main(String[] args) {
int sum = 0;
for (int i = 1; i <= 100; i++) {
sum += i;
}
System.out.println("The sum of numbers from 1 to 100 is " + sum);
}
}
```
阅读全文