[JAVA] What are command line arguments?

I am a beginner in programming. (Learning Java) Write down what you wondered about command line arguments and your own understanding of the question.

Q1: What are command line arguments?

A: The first information passed when you start the program

It seems that the file information is set most often in the command line arguments. (Letters and numbers are OK) You can get the information of the contents of the folder by specifying the path of the folder containing the necessary data when setting. It's convenient because it will bring the file information without you having to write the code one by one. I felt that.

Q2: Where is the command line argument information passed?

A: Argument part of main method

↓ Here ↓ fullsizeoutput_18.jpeg The first call from the java virtual machine (VM) seems to be "public static void main (String [] args)" and is received as a String type array. By the way, it seems that the variable name does not have to be "args".

Q3: Can the main method not receive argument values from elsewhere?

A: The main method arguments are for command line arguments only

main method Since it is called first in the program, you cannot pass arguments in the method as shown in the image below. That's why you need to pass the information as a command line argument. fullsizeoutput_19.jpeg

I think that the content is poor like a beginner, but I hope it helps someone. Please comment if there are any inadequacies in the content. Thank you for reading.

** [Reference source below] **

Recommended Posts

What are command line arguments?
[Java beginner] Command line arguments ... I don't know ~
[Rails] What are params?
[rails] What are Strong Parameters?
[Environment variables] What are rails environment variables?
What are practically final variables?
What are Ruby class methods?
config.ru What are you doing?
What are mass assignment vulnerabilities?
What are Java metrics? _Memo_20200818
Create command line app with maven
What are the rules in JUnit?
[Java] What are overrides and overloads?
[Docker] Use as a command line tool by specifying arguments (wrapper script)