Java: Expressions

Expressions are the basic way to create values. Expressions are created by combining literals (constants), variables, and method calls by using operators. Parentheses can be used to control the order of evaluation.

Types

Every variable and value has a type. There are two kinds of types:

Literals - constants

There is a way to write values of many types (3, 3.0, true, 'a', "abc").

Variables

Every variable must be declared with a type. There are basically three different kinds of variables:

Operators

Operators are used to combine literals, variables, methods calls, and other expressions. Operators can be put into several conceptual groups.

Order of evaluation

The order in which expressions are evaluated is basically left to right, with the exception of the assignment operators. It may be changed by the use of parentheses. See the expression summary for the precedence.