Purpose of String args in the psvm of Java

0 votes

Why do we always pass the argument as String[args]/String[] args to the main method of Java?

May 7, 2018 in Java by misc.edu04
• 1,450 points
4,286 views

1 answer to this question.

0 votes

Let me give you the complete explanation of the Java main method:

public static void main(String[] args)

  • "public" is the access modifier which means main() can be called from anywhere.
  • "static" is a keyword which signifies main() doesn't belong to any specific object
  • "void" is the return type that means that main() returns no value
  • "main" is the name of a function. main() is special because it is the point from where JRE starts the execution of the program.
  • "String[]" means we are going to use an array of String type.
  • "args" is the name of the String[]. "args" is not a keyword, so you can name it anything else and it would not affect your program

public static void main(String[] parameter)

So basically, String[] args represents a collection of Strings that are separated by a space and can be typed into the program on the terminal directly.

answered May 7, 2018 by code.reaper12
• 3,500 points

Related Questions In Java

0 votes
2 answers

Get all the permutations of a string in Java

You could use recursion to do this.  Try ...READ MORE

answered Aug 21, 2019 in Java by Sirajul
• 59,230 points
1,863 views
0 votes
2 answers

What is the easiest way to iterate through the characters of a string in Java?

There are two approaches to this: for(int i ...READ MORE

answered Aug 19, 2019 in Java by Sirajul
• 59,230 points
1,507 views
0 votes
1 answer

What is the difference between main(String[] args) and main(String... args) in Java?

String[] is used to accept a single parameter ...READ MORE

answered Sep 6, 2019 in Java by Piya
3,449 views
0 votes
2 answers

What is the use of toString method in Java and how can I use it ?

Whenever you require to explore the constructor ...READ MORE

answered Aug 23, 2018 in Java by Daisy
• 8,120 points
3,814 views
0 votes
3 answers

Check if a String is numeric in Java

Java 8 Lambda Expression is used: String someString ...READ MORE

answered Sep 3, 2018 in Java by Daisy
• 8,120 points
3,384 views
0 votes
2 answers

Generate an alpha-numeric string randomly

Java supplies a way of doing this ...READ MORE

answered Jul 18, 2018 in Java by Daisy
• 8,120 points
2,237 views
0 votes
1 answer

How do I create a Java string from the contents of a file?

If you're looking for an alternative that ...READ MORE

answered Apr 19, 2018 in Java by Rishabh
• 3,620 points
949 views
0 votes
2 answers

Counting no of Occurrence of a particular character inside a string in Java

We can find out the no. of ...READ MORE

answered Sep 7, 2018 in Java by Sushmita
• 6,910 points
2,315 views
0 votes
1 answer

Maximum depth of the java call stack

Well, there is no definite depth. It ...READ MORE

answered Jul 24, 2018 in Java by code.reaper12
• 3,500 points
1,941 views
0 votes
1 answer

Optional return type of getter() in Java 8

Well, you can do that but originally ...READ MORE

answered Oct 23, 2018 in Java by code.reaper12
• 3,500 points
577 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP