CrazyEngineers
  • doubts in java

    Varsha0802

    Member

    Updated: Oct 25, 2024
    Views: 1.1K
    hi.............i want to take an array of integers as input using command line arguments. how can i do it? and please tell me what are environment variables? are they related with classpath?
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Manish Goyal

    MemberSep 26, 2010

    Basic method of passing command line argument in java is as follow

    java <program name> a1 a2 a3 .....

    Now for declaration of command line argument we use this statement ,which is must for every java program

    public static void main(String args[])

    array can be declared as shown below

    int a[]=new int[6];

    Now since command line argument are in string form you can convert it into integer form by using this

    int n=Integer.parseInt(args[0]);

    For rest ,i hope you can use your programming skills. 😀
    Are you sure? This action cannot be undone.
    Cancel
  • Morningdot Hablu

    MemberSep 26, 2010

    Varsha0802
    hi.............i want to take an array of integers as input using command line arguments.
    Can you post your code so that we can help you.
    Are you sure? This action cannot be undone.
    Cancel
  • Varsha0802

    MemberOct 8, 2010

    thanks..............i got my answer....................
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register