最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

【Day-2】Java自學(xué)筆記 - HelloWorld

2023-01-03 00:18 作者:浩淚  | 我要投稿

1.Java程序的過程能夠被簡化為三步:

? 在文本編輯器輸入和把它保存成文件 -?HelloWorld.java

? terminal窗口編譯這個文件 - javac HelloWorld.java

??terminal窗口運(yùn)行這個文件 - java HelloWorld.java

2.Hello World

Ouput:?

3.分析一下上面的代碼

時間復(fù)雜度:O( 1 ).? ?// 待分析

空間復(fù)雜度:O( 1 ).? ?// 待分析

<1>. class定義 -?使用Class關(guān)鍵字來聲明了一個新類

<2>. HelloWorld - 類名

<3>. main方法

在Java編程語言中,每一個應(yīng)用都應(yīng)該包含一個main方法。main方法時Java程序的主入口。而且它是強(qiáng)制性的。

? public :JVM無論在哪都可以執(zhí)行main方法

? static :? 主要方法是在沒有對象的情況下調(diào)用。修飾符public和static可以按任意順序編寫?. [ ? ]

? void : main方法沒有返回任何東西

??main() :?JVM中配置的名稱。main方法必須在類定義內(nèi)。編譯器總是從主函數(shù)開始執(zhí)行代碼。[?Name configured in the?JVM. The main method must be inside the class definition. The compiler executes the codes starting always from the main function. ]?

??String[] :?main方法接受單個參數(shù),即String類型的元素?cái)?shù)組。

4. 注意點(diǎn)

?? 程序定義的類名為HelloWorld,與文件名(HelloWorld.java)相同。這不是巧合。在Java中,所有代碼都必須駐留在一個類中,并且最多有一個公共類包含main()方法。【?The name of the class defined by the program is HelloWorld, which is the same as the name of the file(HelloWorld.java). This is not a coincidence. In Java, all codes must reside inside a class, and there is at most one public class which contains the main() method.

???按照慣例,主類(包含主方法的類)的名稱應(yīng)該與保存程序的文件的名稱匹配。【?By convention, the name of the main class(a class that contains the main method) should match the name of the file that holds the program.

???每個Java程序都必須有一個與文件名匹配的類定義(類名和文件名應(yīng)該相同)。【 Every Java program must have a class definition that matches the filename (class name and file name should be same). 】

5. sout

System.out.println("Hello, World"); - 可以通過在idea里打sout快速生成。這個會在控制臺輸出Hello,World


【Day-2】Java自學(xué)筆記 - HelloWorld的評論 (共 條)

分享到微博請遵守國家法律
东明县| 嘉义市| 朝阳县| 崇文区| 寿宁县| 双桥区| 临高县| 定安县| 正定县| 太谷县| 沅陵县| 左贡县| 庄河市| 铅山县| 柳州市| 都江堰市| 丰台区| 应城市| 西林县| 兴义市| 正宁县| 祁连县| 多伦县| 辽阳县| 海宁市| 安图县| 锡林浩特市| 宜宾市| 毕节市| 封开县| 湘乡市| 光泽县| 河池市| 新郑市| 醴陵市| 诸城市| 辽阳县| 突泉县| 宿迁市| 临安市| 吉林省|