Java syntax

A snippet of Java code with keywords highlighted in bold blue font

The syntax of Java is the set of rules defining how a Java program is written and interpreted.

The syntax is mostly derived from C and C++. Unlike C++, Java has no global functions or variables, but has data members which are also regarded as global variables. All code belongs to classes and all values are objects. The only exception is the primitive data types, which are not considered to be objects for performance reasons (though can be automatically converted to objects and vice versa via autoboxing). Some features like operator overloading or unsigned integer data types are omitted to simplify the language and avoid possible programming mistakes.

The Java syntax has been gradually extended in the course of numerous major JDK releases, and now supports abilities such as generic programming and anonymous functions (function literals, called lambda expressions in Java). Since 2017, a new JDK version is released twice a year, with each release improving the language incrementally.