官术网_书友最值得收藏!

The main() function

Java code, like the English language, is read top down and left to right. Even if our project contains many files and many classes, we still need to start reading and executing our code at a specific point. We named this file and class HelloWorld, the same name as our project, because we would like it to be special and contain the public static void main(String[] args) method where the execution of our code will begin. That's quite a mouthful of jargon. For now, just type it out and know that this is the area of our code from where our Java program will begin reading and executing. Once again, this will become much clearer as we begin to learn Java; just know this is the starting point of our Java program. The main() function's code is enclosed in curly brackets:

public class HelloWorld {
public static void main(String[] args) {
}
}

One of the great things about working in an IDE is that it will highlight which brackets correspond to each other. The brackets allow us to place code within other areas of code. For example, our main() method is contained within the HelloWorld class, and the Java code which we're about to write and execute is going to be contained in our main() method. Line 4, which currently contains nothing, is where our program will look to start reading and executing the Java code.

主站蜘蛛池模板: 集贤县| 中山市| 正蓝旗| 昭觉县| 文安县| 松原市| 潼关县| 昌宁县| 高要市| 普安县| 醴陵市| 高州市| 临湘市| 漳平市| 桐城市| 河津市| 视频| 西和县| 乐昌市| 东至县| 洞头县| 阿瓦提县| 沿河| 横山县| 金乡县| 云阳县| 长垣县| 广宗县| 修武县| 泽库县| 宿迁市| 特克斯县| 琼海市| 抚宁县| 宁都县| 陇南市| 昆山市| 舞阳县| 普定县| 中宁县| 手机|