command line arguments in java

It is possible to pass some values from the command line to your Java programs when they are executed. These values are called command line arguments and many times they are important for your program specially when you want to control your program from outside instead of hard coding those values inside the code. Consider the following example :

Example

public class Test {

	public static void main(String args[]) {
		
		System.out.println(args[0]); // oth argument
		System.out.println(args[1]); // 1st argument
		System.out.println("demonstration of command line arguments");
	}
}

Output

One thought on “command line arguments in java

  1. These are really great ideas in concerning blogging.

    You have touched some good things here. Any way keep up wrinting.

Comments are closed.