CS61b class2

public static void main

/**package hello_pkg;*/

public class sumargs {
    public static void main(String[] args){
        int N = args.length;
        int sum = 0;
        int i = 0;
        while(i

args直接读取了从命令行输入的序列

C:\Users\phoeb\IdeaProjects\beginner\src\hello_pkg>javac sumargs.java

C:\Users\phoeb\IdeaProjects\beginner\src\hello_pkg>java sumargs 1 2 3 4 5
15

convert string to int in java

Integer.parseInt(mytstring)

Use library

你可能感兴趣的:(Java)