It is a good habit to adhere to the set of rules that can make your and peers life during and after programming in java comfortable. Remember the below given points while declaring these in your java code :
1)Classes & interfaces : The first letter should be capitalized. If several words are linked together to form the class name then the first letter of the inner word should be capitalized. This format is known as camelCase.
1)Classes & interfaces : The first letter should be capitalized. If several words are linked together to form the class name then the first letter of the inner word should be capitalized. This format is known as camelCase.
Example :
class Employee {}, or
class EmployeePensionCalculator{}
class Employee {}, or
class EmployeePensionCalculator{}
Same rule goes for Interfaces as well.
Example :
interface Runnable{}, or
interface RandomAccess{}
Example :
interface Runnable{}, or
interface RandomAccess{}
2)Methods : The first letter should be lowercase, and then normal camelCase rules should be used. In addition, the names should typically be verb-noun pairs.
Example :
getLocation,
getLocation,
doCalculation,
setCustomerName,
3)Variables : Like methods, the camelCase format should be used, starting with a lowercase letter. Sun recommends short, meaningful names, which sounds good to us.
Example :
buttonWidth,
accountBalance,
myString
4)Constants : Java constants are created by marking variables static and final. They should be named using uppercase letters with underscore characters as separators.
Example :
MAX_SALARY,
MIN_AGE
MAX_SALARY,
MIN_AGE
No comments:
Post a Comment