I want to get an int from the String[] args from main

Posted on 2004-11-16
Last Modified: 2011-09-20
Is it possible to make it an int[] args or something?  Or do I have to convert the string to and int?  If so, what is the best way to do that?

Question by:twibblej
    LVL 92

    Expert Comment

    u need to convert them:

    int[] iargs= new int[args.length];
    for (int i=0; i<args.length; i++)
       iargs[i] = Integer.parseInt(args[i]);
    LVL 13

    Accepted Solution


    int val= Integer.parseInt(args[i]);
    LVL 92

    Expert Comment


    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Java: Convert List<Object[]> to List<MyBean> 3 35
    wordsWithout 49 64
    HashMap Vs TreeMap 12 34
    Unable to start eclipse ? 17 51
    Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
    Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
    Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now