1.6 Java The first program HelloWorld

Program development steps illustrate:

  After development environment set up is completed, we can develop the first Java environment.

  Java developers three-step: write | compile | run.
  

  Java application development three steps:

  

 

 Write your first Java program (HelloWorld):

 1. In the C: \ directory under the new text file, the full file name changed to HelloWorld.java, in which a file named HelloWorld, the suffix must .java

  

 2. Write a program:

public class HelloWorld{
    public static void main(String[] args) {
        System.out.println("Hello,World");
    }
}

  

3. Compile and run the program: 

4. code comments:

//第一行的第三个单词必须和所在的文件名称完全一样,大小写也要一样,大小写也要一样
//public class后面代表定义一个类的名称,类是Java当中所有源代码的基本组织单位:
 public class HelloWorld{
    //第二行是万年不变的固定写法,代表main方法
    //这一行代表程序执行的起点
    public static void main(String[] args) {
        /*
        第三行代表打印输出语句(其实就是屏幕显示)
        希望显示什么东西,就在小括号当中填写什么内容
        */
        System.out.println("Hello,World");
    }
}

  

 

Guess you like

Origin www.cnblogs.com/sdrbg/p/10936489.html