when i should use string[]args and int[]args?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kanasu
    New Member
    • May 2016
    • 1

    when i should use string[]args and int[]args?

    hai..kanasu here. i have doubt in access specifier. if iam using "public void yyy(int[]args)"instead of "public static void main(String args[])" i ll get run time error. in my whole program i am using only integers. then how can i give string []args?
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    First of all, whether you need it or not, you will have declare main as

    Code:
    public static void main(String []args)
    this args is for setting data from command prompt.

    example:
    Code:
    ${JAVA_HOME}/bin/java your.package.TheClass value_1 valu_2
    in your args:
    Code:
    args[0] = value_1
    args[1] = value_2
    if you want to pass numerical value, all you have to do is parse them.
    example:
    Code:
    Integer.parseInt(args[0]);

    Comment

    Working...