All about Command line arguments with example
The arguments which are passed through command line at run-time and which are stored in the array of string class in main method are called as command line arguments.

Write a program to pass command line arguments.

class E
{
 public static void main(String args[])
 {
  int n=args.length;
  int i;
  if(n>0)
  {
   for(i=0;i<n-1;i++)
   System.out.println(args[i]);
  }
  else
  {
   System.out.println("Please enter values");
  }
 }
}

How To Run ?
javac E.java
java E 123 567 NSB
Axact

Narendra

Hello, everyone! I am Narendra Bagul founder of Javanotes9. First of all thank you for visiting my blog. Hope you all like my java notes as well. I'm young part time blogger and a Computer Engineering student. I started blogging as a hobby. Now here I'm sharing my little acquired knowledge about my favorite programming language JAVA.

Post A Comment: