Importance syntax rules when working with JAVA – User friendly Tech help

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

n

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

n

1. Name of Class should start with uppercase letter.
nExample:- 
nMyFirstClass rather than myfirstclass
n
n2.Methods and variables of class should start with lower case (camel case)
nExample:-
nmyMethod is valid rather than MyMethod
n
n3.Name of Class, variables and methods (all known as identifier) should always begin with alphabet or underscore.
nExample:-
n_myMethod is valid rather than 12myMethod
n
nNote:- Java code will still work if we dont follow the above rules but its not recommended.
n
n4.In built keywords of Java cannot be used as name of identifiers.
nExample:-
nwhile is invalid variable name as its defined keyword in java
n
n5.All constant values should be defined in Uppercase letter.
nExample:-
npublic static final String UFTHELP = “Learn Technology”;
n
n6.Each line of code should end with semicolon (;)
nExample:-
nMyClass obj = new MyClass();
n
n7.Most important, JAVA is case sensitive.
nExample all the below variables are different for java:-
nfirstName, FIRSTNAME, FirstName
n
nLearn Java

Was this article helpful?
YesNo

Similar Posts