Following Java Program will show how to take Command Line Argument in JAVA.
/************************************************************************* * * Prints "Hi, Sam. How are you?" where "Sam" is replaced by the * command-line argument. * *************************************************************************/ public class UseArgument { public static void main(String[] args) { System.out.print("Hi, "); System.out.print(args[0]); System.out.println(". How are you?"); } } /*************************** * Program Output * * % java UseArgument Bob * Hi, Bob. How are you? * * % java UseArgument Alice * Hi, Alice. How are you? ***************************/