Java coding Standards
- Usually the variable starts with noun
- every inner word should start with upper case i.e camel case convention.
Ex: Name, rollno, bandwidth, totalNumber.
- constants should contain only upper case letters and words are separated with underscores.
Ex: MAX_SIZE, MIN_PRIORITY, COLLEGE_NAME.
- method should start with lower case and every inner words starts with upper case(this convention is also called camel case convention).
Ex: getName(), getMessage(), toString(), show(), display().
- class name Should starts with upper case letter and if it contain multiple words every inner words also should start with capital letters.
Ex: String StringBuffer NumberFormat CustomerInformation
- interface name starts with capital letters and if it contains multiple words, every inner word also should starts with capital letter.
Ex: Runnable Serializable Clonable
Java Been Coding Conventions
- A java bean is a normal java class with private properties & public getter and setter methods.
Ex:
public class
StudentBeen
{
private String name;
public String
getName()
{
return name;
}
public void
setName(String name)
{
this.name = name;
}
}
Syntax for getterMethod
- Compulsory it should be public & should not contain any arguments.For the non boolean property xxx the following is syntax of getter method
public datatype
getXxx()
{
return xxx;
}
For the boolean
property xxx the following is the syntax
public boolean
getXxx() or isXxx()
{
return xxx;
}
Syntax of setter Method
It should be public
and return type should be void. For any propertyxxx
public void
setXxx(datatype xxx)
{
This.xxx = xxx;
}
No comments:
Post a Comment