wood burning stoves 2.0*
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
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: 42598
    
  65
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: 42598
    
  65
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).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why (String args[]) ??