Java command-line arguments

Source: Internet
Author: User

Command-line arguments are the parameters of the main method string[] args He is an array, args is just a name for the data type, is an array of variables, the name does not matter, the type does not change the line. This is the entry point of the program. 7.4 is shown below:

650) this.width=650; "src=" Http://img.mp.itc.cn/upload/20160815/ac9a5b7900024f5e9cdc12cb7dcc8bdb.jpg "style=" border:0px;margin:0px;padding:0px;font-size:0px; "/>

Figure 7.4

How did he run it? Why pass a string? Like A.txt, why would you double-click him to open Notepad? Because in the double-click when the WinDOS first double-click the path path of the file collection, and then see the suffix name is the. TXT Association is what program, is the Notepad program then the parameters passed in.

That is, when a file is opened in the WinDOS, the file path will be collected, to find out who is to open the suffix, find the program will be submitted to Notepad, this way is called to receive external parameters of the value. 7.41 is shown below:

650) this.width=650; "src=" Http://img.mp.itc.cn/upload/20160815/436682376f104972b784831c6d4f9b2d.jpg "style=" border:0px;margin:0px;padding:0px;font-size:0px; "/>

Figure 7.41

For example, cf games as long as the program to add a parameter, then you can form a window mode. Parameters Some programs are not to be, regardless of the opening of photos or doc documents, he is actually a parameter of the delivery, are the path to a software, the software according to this path to open it.

Why there is a string in a class because it is to receive external parameters. How to run the 7.42 shown:

650) this.width=650; "src=" Http://img.mp.itc.cn/upload/20160815/eda1bfb57eca4cd9848f4a4059fa4446.jpg "style=" border:0px;margin:0px;padding:0px;font-size:0px; "/>

Figure 7.42

Run test, followed by a path called parameters, first he found Java.exe program, found and then put Test d:/a.txt to Java.exe Then analyze the TEST.CALSS to go to the current directory, or go to the classpath, find a go to load the static parameters of this file. After loading the d:/a.txt package into string[] and then the string array called the Main method when the string[] passed over.

That is, the parameters written behind our class, how many do not matter, after writing the JDK will automatically form a string array, and then passed over. Why string arrays, because multiple values can be passed. Why put in a string array? Because the string array is the largest, you can put a number of strings to apply. Different types are also fine, nothing more than when as a string type, the future will be used when the self-conversion can be. 7.43 is shown below:

650) this.width=650; "src=" Http://img.mp.itc.cn/upload/20160815/0f3f6ce309df4f53b8f4c7d0810050a2.jpg "style=" border:0px;margin:0px;padding:0px;font-size:0px; "/>

Figure 7.43

Technology sharing: www.kaige123.com

This article from the "11247808" blog, reproduced please contact the author!

Java command-line arguments

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.