How to display the all of the command line arguments passed to the program in Java

1 Answer

0 votes
// CommandLine Arguments: abcd xyz -h
// MyProgram abcd xyz -h

public class MyClass {
    public static void main(String args[]) {
      	for (int i = 0; i < args.length; i++) {
            System.out.println(args[i]);
        }
    }
}




/*
run:
     
abcd
xyz
-h

*/

 



answered Nov 24, 2023 by avibootz

Related questions

...