answersLogoWhite

0


Best Answer

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
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

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

This answer is:
User Avatar

User Avatar

Learn bay

Lvl 8
2y ago

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

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

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

This answer is:
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... :-) :) :-)

Related questions

What is (string args) in java?

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.


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.


What is string args?

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. Therefore, the array will store: ["This", "is", "just", "a", "test"] To learn more about data science please visit- Learnbay.co


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 create a log In page using java swing?

import javax.swing.JOptionPane; public static void main (String[]args){


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... :-) :) :-)


What is the use of main method in java?

The Main method is the method in which execution to any java program begins. A main method declaration looks as follows: public static void main(String args[]){ } The method is public because it be accessible to the JVM to begin execution of the program. It is Static because it be available for execution without an object instance. you may know that you need an object instance to invoke any method. So you cannot begin execution of a class without its object if the main method was not static. It returns only a void because, once the main method execution is over, the program terminates. So there can be no data that can be returned by the Main method The last parameter is String args[]. This is used to signify that the user may opt to enter parameters to the java program at command line. We can use both String[] args or String args[]. The Java compiler would accept both forms.


How to Write a java program to display hello?

public class Hello{public static void main(String [] args){System.out.println("Hello");}}


Sample code in java programming?

public class Hello { public static void main (String args[]) { System.out.println("Hello World"); } }