answersLogoWhite

0

If you're referring to "args" in the line: "public static void main(String args[])", then it is the name of the array that holds the command line arguments. So, if you called your java program (called myJavaProgram) from the command line using the following line:

java myJavaProgram Hello World "These are args"

Then args would have the following values stored in it:

args[0] = "Hello"

args[1] = "World"

args[2] = "These are args"

If you called your program from the command line like this:

java myJavaProgram Different Args

then args would contain

args[0] = "Different"

args[1] = "Args"

User Avatar

Wiki User

14y ago

Still curious? Ask our experts.

Chat with our AI personalities

TaigaTaiga
Every great hero faces trials, and you—yes, YOU—are no exception!
Chat with Taiga
SteveSteve
Knowledge is a journey, you know? We'll get there.
Chat with Steve
ReneRene
Change my mind. I dare you.
Chat with Rene
More answers

If this is in reference to the "String[] args" passed as a parameter to the "public void static main()" method, then it refers to the list of arguments passed to the class when it is called. Eg: When the following command is executed "java abc xxx yyy" then in the main method of the abc.java, the first parameter of args i.e. args[0] would have "xxx" and the second parameter of args i.e. args[1] would have "yyy". Referring to the 3rd or any other higher element would throw a "IndexOutOfBounds" exception

User Avatar

Wiki User

14y ago
User Avatar

String[] args means an array of sequence of characters (Strings) that are passed to the "main" function. This happens when a program is executed. Example when you execute a Java program via the command line: java MyProgram This is just a test.

To learn more about data science please visit- Learnbay.co

User Avatar

Learn bay

Lvl 8
2y ago
User Avatar

it means that we are declaring a variable args which have String datatype...

User Avatar

Wiki User

12y ago
User Avatar

Add your answer:

Earn +20 pts
Q: What is use of string args in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Write a java program to pass a string have a good day from command line?

public class HaveAGoodDay { public static void main(String[] args) { for (final String arg : args){ System.out.print(arg +" "); } } } compile and run the program: java HaveAGoodDay have a good day. output: have a good day.


What is the argument of main()method?

In Java, the main() method is typically written something like this:public static void main(String [ ] args)The argument is what is in parentheses, in this case: "String [] args". I believe this can also be written as "String args[]". It refers to parameters received by the Java program from the command line. That is, the user can write, for example:java MyClass info1 info2In this example, "info1" and "info2" will be received by the main method, in the args[] array.


Why in java string args is passed in main method?

The String[] args parameter is an array of Strings passed as parameters when you are running your application through command line in the OS. The java -jar command will pass your Strings update and notify to your public static void main() method. To learn more about data science please visit- Learnbay.co


How do you print the message welcometomist in java?

class SecondProgram { public static void main(String args[]) { System.out.println(/welcome/to/mist } }


Can you have two mains in java?

Yes... We can have more than one main in JAVA... Just make the only one main method as public and other as default access specifier.... public class Test { public static void main(String args[]) { } } class Test1 { public static void main(String args[]) { } } class Test2 { public static void main(String args[]) { } } Just copy the above code and try.... Have fun in learning... :-) :) :-)