Java Lesson 03: Int parameters

From Erlands Wiki

Jump to: navigation, search

Now the helper class looks like this instead:

public class ArgumentHelper {
    public static int getArgument(String[] args) {
        return Integer.valueOf(args[0]);
    }
}

And the main class looks like this:

public class MyClass {
    public static void main(String[] args) {
    }
 
    public static void printStuff(int data) {
        System.out.println("You specified: "+data);
    }
}

The program is executed as:

java MyClass 5

Your work is to update the main method so it uses the ArgumentHelper class and the printStuff method to get and output like the following:

You specified: 5
Personal tools