**Demonstrations of Reflections in Math


A+    A−    B  
Home
Algebra
Math Games
Geometry
Private Tutors
Interactive
Trigonometry
Jobs
Teacher Resources

AddThis Social Bookmark Button

How to Pass arguments from Command Prompt To Java

public static void main (Sring[] args)

This example assumes that you are comfortable using the windows command prompt as well as how compiling and running basic java files.
First, use javac to compile the java class below.
public class Arg{

public static void main(String[] args){	 
	System.out.println(args[0]);	
	}

}

 

Example 2. Changing the Class and Parameters

So, what if you don't want to print out the first argument in the command prompt? First, let's recompile Hi.java so that it prints the second argument that is passed,ie args[1].
 public static void main(String[] args){	 
	System.out.println(args[1]);	
	}

 

Top
AddThis Social Bookmark Button