Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

MAIN method

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why the argument for main method is array of Strings
why not int array or someother?
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Java Laguage Specification requires the main method to be declared with the signature
public static void main ( String[] args )
Search the saloon with the key word main and you can find a lot of threads on this.
Regards,
Kalidas.
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Besides being a signature, the 'String' datatype is abstract, allowing you to handle characters and numerics alike.
If you want to pass integers at the command prompt, you will have to parse them as follows.
[hr size="3" width="50"]
[font size =-2]
int x =Integer.parseInt(arg[i])
[/font]
[hr size="3" width="50"]
Here 'arg' is your parameter array and 'i' is the index of the integer parameter.
Hope this helps!
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please note that The Java Ranch has a naming policy, described here and "suthasankar g" is not a valid name.
Please choose one which meets the requirements.
Thanks.
 
I'm all tasted up for a BLT! This tiny ad wants a monte cristo!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic