Naming Convention

Author: Ravi Poswal

Java naming conventions are a collection of common guidelines for naming variables, classes, methods, and other identifiers. These conventions enhance Java applications' uniformity, readability, and maintainability.

1. Class Name

Class name shoul be start with capital letter i.e first letter of each word in a class name should be capitalized. This naming style is called CamelCase (Upper Camel Case) and is used to improve readability and follow standard Java coding conventions. Example:

class Student, class TeacherStudent

2. Variable Name

Variable names should begin with a lowercase letter; if the name has more than one word, the subsequent words should begin with a capital letter. Example

int totalMarks

3. Method Name

Java method names follow the camelCase naming style. In this way, the first letter of the method name is lowercase, and if the method name contains more than one word, the first letter of each successive word is capitalized. This approach improves the code's readability while adhering to standard Java programming practices. Example

calculateTotal(), displayResult(), getStudentDetails(), and printData()

4. Constant Name

Constants are always written in uppercase letters, and words can be separated by an underscore (_). Example

int MIN_VALUE =10;

5. Package Name

Package name is written in small case. it should be beloging to the project. Example

package register;

java.util.*;