Programming





Java Naming Conventions

Java Naming Conventions


by Administrator | 25-Mar-2020
Java

Tags:  Core Java  Naming Convention

Share: 


We should keep these things in mind while defining identifiers. These are not a compulsion and will not result in a compile-time error. These are more like suggestions and everyone in the industry follows it:

a. Naming A Custom Type

  1. The name should start with an uppercase character.
  2. The remaining characters should be in lowercase if the identifier consists of one word.
  3. If the name contains more than one word then the first character of every word should be in uppercase and the remaining characters should be in lowercase.

Examples: Executable, Student, BatchTiming, CourceDetails, UserInFormation etc.

b. Naming a Method or Object or Variable

  1. The name should start with a lowercase letter.
  2. If it contains multiple words then from second word onwards the first character should be uppercase and the remaining should be in lowercase. For e.g. email, employeePhone, branchName, getCourceDetailsByCourceId(), getName(), isValid() etc.

c. Naming a Constant

  1. All the characters should be uppercase.
  2. If the name contains multiple words then we need to use _ (underscore) symbol as a separator between two words. For eg MIN_VALUE, FULL_COURCE_FEE, etc.

Comments:


There are no comments.

Enter a new Comment:










Copyright Šprgrmmng. All rights reserved.