"KEEP LEARNING, DON'T STOP."
"KEEP LEARNING, DON'T STOP."
Passing the value at a runtime to main method is called command line argument. Any type of value we can pass in main method array argument.
Command line argument is the argument that passed to a program main method at run time when we run our program.
Any type of value we can pass in main method array argument.
class Test { public static void main(String args[]) { int n = args.length; for(int i=0; i<n; i++) { System.out.println("args["+i+"] = "+args[i]); } } }
C:\Users\Nature\Desktop\Java>javac Test.java //passing a value at runtime to an array in main method. C:\Users\Nature\Desktop\Java>java Test 1 2 3 4 args[0]= 1 args[1]= 2 args[2]= 3 args[3]= 4