Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (13.1k points)

Can anyone help me explain the below program:

public static void main(String[] args)

What is String[] args?

1 Answer

0 votes
by (26.7k points)

Basically, it is used for command-line arguments, so if you run :

java MyProgram one two

Then, args will contains ["one","two"]

public static void main(String [] args) {

    String one = args[0]; //=="one"

    String two = args[1]; //=="two"

}

It will help your application to run in a particular way.

I hope this will help.

Want to become a Java expert? join Java Training now!!

Want to know more about Java? Watch this video on Java Tutorial for Beginners | Java Programming:

Related questions

0 votes
1 answer
asked Sep 2, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
0 votes
1 answer
asked Jan 27, 2020 in Java by angadmishra (6.5k points)
0 votes
1 answer

Browse Categories

...