Importance syntax rules when working with JAVA

Lets learn some of the basic and critical rules that we should know as JAVA developers.

Being aware of a single shortcoming within yourself is far more useful than being aware of a thousand in someone else.

1. Name of Class should start with uppercase letter.
MyFirstClass rather than myfirstclass

2.Methods and variables of class should start with lower case (camel case)
myMethod is valid rather than MyMethod

3.Name of Class, variables and methods (all known as identifier) should always begin with alphabet or underscore.
_myMethod is valid rather than 12myMethod

Note:- Java code will still work if we dont follow the above rules but its not recommended.

4.In built keywords of Java cannot be used as name of identifiers.
while is invalid variable name as its defined keyword in java

5.All constant values should be defined in Uppercase letter.
public static final String UFTHELP = “Learn Technology”;

6.Each line of code should end with semicolon (;)
MyClass obj = new MyClass();

7.Most important, JAVA is case sensitive.
Example all the below variables are different for java:-
firstName, FIRSTNAME, FirstName

Learn Java

Leave a Reply

Your email address will not be published. Required fields are marked *