It is a rule that is used to identify our identifiers in a code such as class, package, variable, constant, method, etc.
If we don’t follow naming convention rules, it may generate confusion in the code.
Advantages of naming convention rules:-
The code can be read easily.
The name should not start with a special character such as $, %, @.
Easy to understand the code.
If we know about the naming convention rule, we can easily write or implement the things in code.
Types:-
CamelCase (camelCase): If the name contains multiple words, the first letter of the word always in small letter and after that each word with a capital letter.
Example: lastName, mostTalented, etc.
PascalCase: If the name contains multiple words, the first letter of every word is in capital letter.
Example: ActionListner, AudioWriter, etc.
Method:-
Always use camelcase for the method name.
Such as println(), main(), etc.
Syntax:-
Class Student
{
Void M1()
{
Code
}
}
Class:-
Always use PascalCase.
Such as Employee, Student, etc.
Syntax:-
class Student
{
code
}
Variable:-
Always use camelcase.
Such as id, temp, etc.
Syntax:-
class Student
{
int id;
code
}
Package:-
Always use camelcase.
Such as java, lang, etc.
If the name contains multiple words, they are separated by dots (.) like java.lang.package.
Syntax:-
package java.lang.package;
class Student
{
code
}
Liked By
Write Answer
What is the role of naming convention rule in java?
Join MindStick Community
You have need login or register for voting of answers or question.
Rahul Roi
22-Jul-2019Java Naming Convention Rule:-
Advantages of naming convention rules:-
Types:-
CamelCase (camelCase): If the name contains multiple words, the first letter of the word always in small letter and after that each word with a capital letter.
Example: lastName, mostTalented, etc.
PascalCase: If the name contains multiple words, the first letter of every word is in capital letter.
Example: ActionListner, AudioWriter, etc.
Method:-
Syntax:-
Class:-
Syntax:-
Variable:-
Syntax:-
Package:-
Syntax:-