Netbeans how to set command line arguments in Java

前端 未结 10 1315
陌清茗
陌清茗 2020-11-27 16:36

I am trying to set command line arguments in a Netbeans 7.1 Java project on Windows 7 64 bit.

Netbeans is not passing the arguments I give it.

I go to

10条回答
  •  暖寄归人
    2020-11-27 17:02

    import java.io.*;
    class Main
    {
    public static void main(String args[]) throws IOException
    {
        int n1,n2,n3,l;
        n1=Integer.parseInt(args[0]);
        n2=Integer.parseInt(args[1]);
        n3=Integer.parseInt(args[2]);
    
        if(n1>n2)
        {
            l=n1;
        }
        else
        {
            l=n2;
        }
    
        if(l

    Consider above program, in this program I want to pass 3 no's from Command Line, to do so.

    Step 1 : Right Click on Cup and Saucer icon, u'll see this window 1

    Step 2: Click on Properties

    Step 3: Click Run _> Arguments _> type three no's eg. 32 98 16 then click OK. Plz add space between two arguments. See here 2

    Step 4: Run the Program by using F6.

提交回复
热议问题