In java programming, sometimes we want to pass information into a program during run time. We can do so by using
All command line argument
CLA
Example: Display all command line argument.
1 2 3 4 5 6 7 8 9 10 11 | public class CommandLineArgument { public static void main(String args[]) { System.out.println(" args[0] = " + args[0]); System.out.println(" args[1] = " + args[1]); System.out.println(" args[2] = " + args[2]); System.out.println(" args[3] = " + args[3]); System.out.println(" args[4] = " + args[4]); System.out.println(" args[5] = " + args[5]); } } |
Command Line argument
1 2 | >javac CommandLineArgument.java > java CommandLineArgument Ram Mohan Sohan Ramesh Ritu Nitu |
Result
1 2 3 4 5 6 | args[0] = Ram args[1] = Mohan args[2] = Sohan args[3] = Ramesh args[4] = Ritu args[5] = Nitu |