This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes why (String args[]) ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "why (String args[]) ??" Watch "why (String args[]) ??" New topic
Author

why (String args[]) ??

Abhinav Yadav
Ranch Hand

Joined: Nov 08, 2009
Posts: 34
why does argument of main method contains data type of args array as string and why not integer or float or double?


No Dream Too Big
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41599
    
  55
Because the command line environment (from where applications are started) only understands characters, and has no notion of numbers. Plus, strings can be converted into numbers if need be, but not vice versa.


Ping & DNS - my free Android networking tools app
Gokul Nanthakumar
Ranch Hand

Joined: May 11, 2010
Posts: 56
Main Method is the communication medium between jvm and user, so it should receive the input from user in user understandable format ie String...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41599
    
  55
I'm sorry, but that doesn't make sense - a number is just as understandable by a user as a string.
Gokul Nanthakumar
Ranch Hand

Joined: May 11, 2010
Posts: 56
My view is as long the number is not associated with some thing it does not have any meaning, 15 can represent a day in a month or money or age, etc etc. it can be a symbol as well. but words are self explanatory (when they are meaningful).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: why (String args[]) ??