Thursday, February 18, 2016

Java Identifiers Part 2

Hi All...!

Today post is about the regulations we have to follow when we creating a Java Identifiers, this is not a must to follow if we follow these regulations we can create easy to read codes and quality code.

Let's see what are these regulations,

1) class names

class names must start with capital letters and if class name have more than one word each words' first letter must be capitalize.

ex: NewClass, MyClass

2) Interface names

Same as the class names

3) package names

all letters in package name must be simple

ex: newpackage, homepackage

4) method names

Method names must follow camel case, that means all letters in the first word must be simple and if there are more than one word for the name all words after first word must capitalize it's first letter.

ex: printBill, selectLetter

5) variable names

Same as the method names.

6) constant names

All letters must be capitalize and if name contain more than one word those words must connect by using underscore "_".

ex: MAX_VALUE, MAX_HEIGHT

No comments:

Post a Comment