The syntax of Java is largely derived from C++.
Unlike C++, which combines the syntax for structured, generic, and object-oriented programming, Java was built almost exclusively as an object-oriented language.
All code is written inside a class, and everything is an object, with the exception of the primitive data types (e.g. integers, floating-point numbers, boolean values, and characters), which are not classes for performance reasons.
Unlike C++, Java does not support operator overloading or multiple inheritance for classes. This simplifies the language and aids in preventing potential errors and anti-pattern design.
Java uses similar commenting methods to C++. There are three different styles of comments:
- a single line style marked with two slashes (//),
- a multiple line style opened with /* and closed with */,
- and the Javadoc commenting style opened with /** and closed with */.
The Javadoc style of commenting allows the user to run the Javadoc executable to compile documentation for the program.