Java Program to Command Line Arguments in NetBeans

Free Java courses with 37 real-time projects - Learn Java

Program 1

package testcommandline;

public class TestCommandLine {

    public static void main(String[] args) 
    {
            System.out.println("Total Arguments: "+args.length);
            System.out.println("First Argument:"+ args[0]);
            System.out.println("Second Argument:"+ args[1]);
            System.out.println("Third Argument:"+ args[2]);
            System.out.println("Fourth Argument:"+ args[3]);
            System.out.println("Fifth Argument:"+ args[4]);
            if(args[0].equalsIgnoreCase(args[1]))
                System.out.println("Same");
            else
                System.out.println("Not Same");
    }
    
}

 

If you are Happy with DataFlair, do not forget to make us happy with your positive feedback on Google

follow dataflair on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *