以下是从1加到1000的Java代码:
public class Sum { public static void main(String[] args) { int sum = 0; for (int i = 1; i <= 1000; i++) { sum += i; } System.out.println("The sum from 1 to 1000 is " + sum); } }
以下是从1加到1000的Java代码:
public class Sum { public static void main(String[] args) { int sum = 0; for (int i = 1; i <= 1000; i++) { sum += i; } System.out.println("The sum from 1 to 1000 is " + sum); } }