sum.java

来自「this gives details of the network progra」· Java 代码 · 共 24 行

JAVA
24
字号
// Sum Java class// This sample reads a bunch of integers entered as command line arguments//   sums them up and prints the sum and average.public class Sum {    public static void main( String nums[] ) {	// create an int array of the right size	int[] ivals = new int[nums.length];	// convert each string to integer	for (int i=0;i<nums.length;i++) {	    ivals[i]= Integer.parseInt(nums[i]);	} 	// sum everything up	int total=0;	for (int i=0;i<ivals.length;i++) {	    total += ivals[i];	}	System.out.println("Sum is " + total);    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?