top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

We did not get an error when we don't pass any command line arguments to a Java program, why?

+2 votes
64 views
We did not get an error when we don't pass any command line arguments to a Java program, why?
posted Mar 3, 2016 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Whenever we don't pass any argument to java program but we didn't get error because an array of string is always a parameter which main program receives.when we don't pass anything array of string will be there always but this time length of array of string will be zero.

public static void main(String[] args) {
   if (args.length == 0) {
      System.out.println("No cmd parameters passed");
   }
}

here array of string args is passed and when we pass nothing, length of args is zero but args is passed.

answer Mar 8, 2016 by Shivam Kumar Pandey
Similar Questions
0 votes

I have program which takes special character as parameter in command line for a program in java.
But I can not send * (asterisk) as input for my program.

Give me some explain and solution for my problem.

+1 vote

Is it possible to pass command line arguments to C programs? If yes, can you write down the prototype for main function with command line arguments?

+3 votes

In Java
I am using statement a += b where a is int and b is double, when I use a += b, it won't give error but in case of a = a + b it gives error, why ?

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...