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.
Identifiers in java language are the names of Java packages, Java classes and objects, interfaces, methods, and variables in Java. They are basically the name of any element. For example, in the program above, String, main, args and println are Java identifiers.
Identifiers in Java are case-sensitive, there are some basic conventions that are to be followed while naming any identifier, they can contain:
• Any Unicode character, which is a letter or a digit
• Special signs such as an underscore
• A $ sign ( a currency sign) • Java identifiers cannot start with a digit or be same as a reserved word.
The following list shows the reserved words in Java. These reserved words may not be used as constant or variable or any other identifier names.
There are 3 types of comments in Java language:
• Single Line Comment in Java:
The single line comment is used to comment only one line.
// This is an end-of-line comment
• Java Multi Line Comment:
The multi line comment is used to comment multiple lines of code.
/* This is a multi-line comment. It may occupy more than one line. */
• Java Documentation Comment:
The documentation comment is used to create documentation API. To create documentation API, you need to use javadoc tool.
/** * This is a documentation comment. * * @author Varun Singh */
Like other languages, it is possible to modify classes, methods by using modifiers. There are two categories of modifiers:
• Access Modifiers - default, public , protected, private
• Non-access Modifiers - final, abstract, strictfp
Following are the types of variables in Java:
• Local Variables
• Class Variables (Static Variables)
• Instance Variables (Non-static Variables)
Thank you for reading this article, and if you have any problem, have a another better useful solution about this article, please write message in the comment section. We will be very happy to hear that.