Java syntax is the set of rules that define how a Java program is written. It is mostly derived from C and C++, The class is a blueprint (plan) of the class (methods,variable object and Everything inside the class). It can be defined as a logical template that share common properties and methods.
Here are some of the key features of Java syntax :
Name of Class :- A class should always start with an uppercase first letter. The name of the java file must match the class name. When saving the file,save it using the class name with add “.java” Extantion
Case sensitivity :- Java is a case-sensitive language, which means that the names of classes, variables, and methods must be written in the same case throughout the program. For example, the name myClass is different from MyClass.
Whitespace :- Whitespace is not significant in Java, which means that you can use spaces, tabs, and newline characters to format your code however you like. However, it is a good practice to use whitespace to make your code more readable.
Keywords :- Java has a set of keywords that have special meaning to the compiler. These keywords cannot be used as identifiers for classes, variables, or methods.
Identifiers :- Identifiers are the names of classes, variables, and methods. They can be any combination of letters, numbers, and underscores, but they must start with a letter.
Statements :- Statements are the basic units of execution in Java. They can be instructions to perform a task, declarations of variables, or control flow statements.
Expressions :- Expressions are combinations of operators and operands that evaluate to a value.
Comments :- Comments are used to explain the code and make it more readable. They are not executed by the compiler.
Main Method :- The method main() is the main entry point into a Java program; this is where the processing starts. Also allowed is the signature ” public static void main(String… args) “.
Method Names :- The method names should start with a lowercase letter .Underscores are allowed, but not recommended. Also allowed are digits and currency symbols.
Access Modifiers :- These modifiers control the scope of class and methods.
{
public static void main(String[] args)
{
//Statement of programme
}
}
Note :- Hare i Give Syntax of Class With Class Name “Demo”.