Run the first Hello world! The program

runs the first Hello world! Program

edit java program

  1. Open Notepad or other editor, enter the following code, save the file as, he will prompt to modify the suffix name problem, do not care about him. I use notepad++ here, because the notebook that comes with Windows has no color highlighting function, it is not intuitive enough. The installation of notepad++ is not mentioned here
class Demo
    public static void main(String[] args) 
        System.out.println("Hello World!");

Running code

  1. Find the file by command prompt. Location, here introduces the common command prompt
    • cd Open the directory
    • dir View
    • ipconfig View the network information of this machine
    • c: Switch the drive letter, here is the switch to c Disk
    • cd.. Back up one layer
    • ping View the current host's network connection status
    • java java run
    • javac java compile


when executing javac If there is other information in, the code is wrong. You need to go back to the text to check the code, pay attention to capitalization. If it is the same as my interface, congratulations, it has run perfectly. The java program

explains the code meaning

  • What are the meanings of these lines of code?
    • //: Two "/" for comments, do not participate in code execution
    • main: is a function that represents the entry of the program
    • System.out.println(): output statement, parentheses What to write in the inside, string to add double quotes
class Demo//class: Class Demo: the name of the class, it needs to be consistent with the file name{//main: a function, representing The entry of the program 
    public static void main(String[] args) 
        // means the meaning of printing. () is the content to be printed, here will display the printed content in the command prompt window, that is the black and white window 
        //"" represents the character StringSystem.out.println("Hello World!");