Free Java Guide

These tutorials will introduce you to Java programming Language. You'll compile and run your Java application, using Sun's JDK. It's very easy to learn java programming skills, and in these parts, you'll learn how to write, compile, and run Java applications. Before you can develop corejava applications, you'll need to download the Java Development Kit (JDK).


Java Command Line Arguments

This class demonstrates how command line arguments are passed in Java. Arguments are passed as a String array to the main method of a class. The first element (element 0) is the first argument passed not the name of the class.

Source Code

An example that prints in the command line arguments passed into the class when executed. 

public class ReadArgs
       public static final void main(String args[])
                for (int i=0;i<args.length;++i)
                         System.out.println( args[i] );

Sample Run

With the following command line, the output shown is produced.

java ReadArgs zero one two three


The following command line arguments were passed:
arg[0]: zero
arg[1]: one
arg[2]: two
arg[3]: three