Tuesday, September 10, 2013

Clarification of String[] args length ....

String args[] length:

Everyone says that the length of String args[] in main is zero if no command line arguments were passed to the java application.

means..

public class A{
      public static void main(String args[]){
      }
}//

suppose if we don't pass any argument to this java application, then the length of args array is zero,
we can see by using the command " System.out.println(args.length);"

- There are two types we can create zero size String array.

1) String[] args=new String[0];

2) String[] args={};

java uses second statement and pass that object to our "public static void main" method, but not first one because size must be specified before adding any string to it.

So, If any one want's you for clarification on String[] args in main method, you can write and explain him.

Please let me know if any mistakes are here in the current post. please give your feedback at nagarjuna.lingala@gmail.com 

No comments:

Post a Comment