doubts in java

Varsha0802
@varsha0802-YohNRX โ€ข Oct 25, 2024

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?

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Manish Goyal

    @manish-r2Hoep • Sep 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. ๐Ÿ˜€

  • Morningdot Hablu

    @morningdot-6Xuj4M • Sep 26, 2010

    Varsha0802hi.............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.

  • Varsha0802

    @varsha0802-YohNRX • Oct 8, 2010

    thanks..............i got my answer....................