search
HomeJavaJavagetting StartedIn-depth analysis of the first java program

In-depth analysis of the first java program

When we learn java programming, the first Java program we start with is HelloWorld. Now let's go back and analyze the program in depth.

(Learning video sharing: java teaching video)

There are three steps to successfully run a Java program: write, compile, run

Write:

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

		System.out.println("Hello, World!");

	}

}

Compile:

javac HelloWorld.java

Run:

java HelloWorld

Summary of the first Java program

1. Java program writing— Compilation-running process

编写:将编写的代码保存在一个以".java"结尾的源文件中;

编译:使用javac命令编译java源文件,这将会生成一个以".class"结尾的字节码文件,格式:javac 源文件名.java

运行:使用java命令解释运行由javac生成的以".class"结尾的字节码文件,格式:java 类名

2. Class declaration

You can declare multiple classes in a java source file, but at most one class can be declared public, and this is required The class name of a class declared as public must be the same as the source file name.

3. The entrance of the program

The entrance of the program is the main method, and the fixed format is:

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

4. Output statement

System.out.print();	//只输出
System.out.println();	//先输出后换行

5. Execution statement The end of

Each line of execution statement ends with ";"

6. Comments

Categories: single-line comments, multi-line comments, document comments

Format:

Single-line comments: //
Multi-line comments: /* …*/
Documentation comments: /**…*/

Java API Documentation

Java API documentation is a description of how to use the class library provided by java. You can directly enter the API provided by Oracle's official website to view and use it.

Related recommendations: java introductory tutorial

The above is the detailed content of In-depth analysis of the first java program. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:csdn. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.