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

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.

主站蜘蛛池模板: 高雄县| 东方市| 景东| 疏勒县| 个旧市| 阿拉尔市| 瓦房店市| 顺昌县| 舒兰市| 石家庄市| 泰和县| 瑞昌市| 深州市| 陈巴尔虎旗| 稻城县| 会泽县| 梧州市| 慈利县| 扶绥县| 苏尼特左旗| 达日县| 普兰县| 莱西市| 泗阳县| 大邑县| 南通市| 永新县| 怀安县| 师宗县| 灵寿县| 蒙城县| 清镇市| 葵青区| 根河市| 图木舒克市| 崇明县| 溧水县| 潜山县| 宜宾县| 永平县| 澄江县|