国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(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的評論 (共 條)

分享到微博請遵守國家法律
灌阳县| 祁连县| 石首市| 永兴县| 阿鲁科尔沁旗| 东港市| 长顺县| 台东县| 屏东市| 亚东县| 抚远县| 三原县| 平安县| 达孜县| 西宁市| 香港| 吉安县| 千阳县| 自贡市| 呼和浩特市| 东城区| 仁寿县| 松溪县| 唐河县| 康定县| 余姚市| 沭阳县| 保德县| 古田县| 江源县| 电白县| 错那县| 承德县| 左贡县| 莱西市| 泗洪县| 九江市| 山阳县| 湖北省| 驻马店市| 额济纳旗|