Java基础语法CheatSheet

Java Programming Cheatsheet

from https://introcs.cs.princeton.edu/java/11cheatsheet/
This appendix summarizes the most commonly used Java language features and APIs in the textbook.

Hello, World.

Editing, compiling, and executing.

Built-in data types.

Declaration and assignment statements.

Integers.

!

Floating-point numbers.

Booleans.

Comparison operators.

Printing.

Parsing command-line arguments.

Math library.

Java library calls.

Type conversion.

Anatomy of an if statement.

If and if-else statements.

Nested if-else statement.

Anatomy of a while loop.

Anatomy of a for loop.

Loops.

Break statement.

Do-while loop.

Switch statement.

Arrays.

Inline array initialization.

Typical array-processing code.

Two-dimensional arrays.

Inline initialization.

Command line.

Redirection and piping.


Functions.

Libraries of functions.

Using an object.

Instance variables.

Constructors.

Instance methods.

Classes.

Object-oriented libraries.

Java’s String data type.

The full java.lang.String API

Java’s Color data type.

The full java.awt.Color API

Iterable.