*** Welcome to piglix ***

Java syntax


The syntax of the Java programming language 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++, in Java there are no global functions or variables, but there are 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 types, which are not represented by a class instance for performance reasons (though can be automatically converted to objects and vice versa via autoboxing). Some features like operator overloading or unsigned integer types are omitted to simplify the language and to avoid possible programming mistakes.

The Java syntax has been gradually extended in the course of the eight major JDK releases support capabilities such as generic programming and function literals (called lambda expressions in Java).

An identifier is the name of an element in the code. There are certain standard naming conventions to follow when selecting names for elements. Identifiers in Java are case-sensitive.

An identifier can contain:

An identifier cannot:

Integer literals are of int type by default unless long type is specified by appending L or l suffix to the literal, e.g. 367L. Since Java SE 7, it is possible to include underscores between the digits of a number to increase readability; for example, a number 145608987 can be written as 145_608_987.


...
Wikipedia

...