Java Language
Internal
Lexical Structure
Keywords
- synchronized. See synchronized statement and synchronized modifier.
- static. See class variables.
Statements
synchronized
The synchronized statement acquires a mutual-exclusion lock on behalf of the executing thread, executes a block, then releases the lock. While the executing thread owns the log, no other thread may acquire the lock.
synchronized (expression) block
The type of expression must be a reference type.
Also see:
return
Control-flow statement.
Modifiers
Method Modifiers
synchronized
A synchronized class method synchronizes on the monitor associated with the Class object of that class.
A synchronized instance method synchronizes on the monitor associated with this - the object instance it is invoked onto.
Also see:
default
final
Literals
Operators
Types
Java is a statically typed language, which means that every variable and every expression has a type that is known at compile time.
Java is strongly typed language, because the types limit the values a variable can hold or that an expression can produce, limit the operations supported by those types and determine the meaning of operations.
null Type
Primitive Types
The primitive types are boolean and the numeric types.
The numeric types are the integral types byte, short, int, long and char, and the floating-point types float and double.
Reference Types
There are four kinds of reference types: class types, interface types, type variables and array types.
Class Types
Interface Types
Type Variables
Array Types
Values
The value of a reference type is a references to an object instance.
In case of a lambda expressions, the value of the lambda expression is the reference to a functional interface instance.
Variables
A variable is a storage location and has an associated type - the compile-time type - that is either a primitive type or a reference type.
The value of a variable is changed by an assignment or by a prefix/postfix increment/decrement operators.
There are eight kinds of variables:
Class Variable
A class variable is a field declared using the keyword static within a class declaration, or with or without the keyword static within an interface declaration.
Instance Variable
An instance variable is a field declared within a class declaration without using the keyword static.
Array Component
Array components are unnamed variables that are created and initialized to default values whenever a new object that is an array is created.
Method Parameter
Method parameters name argument values passed to a method. For every parameter declared in a method declaration, a new parameter variable is created each time that method is invoked. The new variable is initialized with the corresponding argument from the method invocation.
Constructor Parameter
Constructor parameters name argument values passed to a constructor. For every parameter declared in a constructor declaration, a new parameter variable is created each time a class instance creation expression or explicit constructor invocation invokes that constructor. The new variable is initialized with the corresponding argument from the creation expression or constructor invocation.
Lambda Parameter
A lambda parameter name argument values passed to a lambda expression body. For every parameter declared in a lambda expression, a new parameter variable is created each time a method implemented by the lambda body is invoked, and initialized with the corresponding argument value from the invocation.
Exception Parameter
An exception parameter is created each time an exception is caught by a catch clause of a try statement.
Local Variable
Local variables are declared by local variable declaration statements. The local variables are created whenever the flow of control enters a block of a for statement.
Expressions
Interface
An interface groups related methods together into a contract.
Class
Anonymous Class
Can be used for behavior parameterization.