- On
- By
- 0 Comment
- Categories: Basic, Java basic
Naming Conventions in Java programming language
Naming Conventions in Java programming language
In this tutorial, we will discuss about Naming Conventions in Java programming language
Naming Convention in Java language, which is a rule to follow as you decide what to name your identifiers such as class, package, variable, constant, methods etc..
All the classes, interfaces, packages, methods, and fields of Java coding are given according to the Java naming convention
- Class name
Class names should be nouns always begins with an uppercase letter. And if there are multiple words in the class name, then each word must begin with a capital letter.
class My_Vehicle{ } class Bus{ }
2.Interface name
Interface name must start with the Capitalized letter just like class names and be an adjective.
interface Runnable{ }
3.Method name
Method name should be A verb and must start with a lower camel case convention to look like Object and variables. The first letter is a lower case and if there are multiple words the first letter of each internal word is capitalized.
void get_Method(){ } void set_Method(){ }
4.variable name
Variable name should not start with number or underscore(‘_’) or $ sign
In the Java naming conversions, the variable name must start with a lower case letter and if there are multiple words in the name, use mixed case
String myName; int orderNumber; double totalSalary;
4.Object name
In the java naming conversions, object name must start with the lowercase letter and if there are multiple words in the name use lower camel case.(you need to use Upper case for starting letters for the word except for the starting words)
My_Class obj=new My_class(); Scanner sc = new Scanner(System.in);
5.package name
the package name must start with lower case letter. And when there are multiple words in the package name, then you need to use upper case for all words except for the starting words
java, lang, sql, util etc
6.constants name
constants name must start with the uppercase letter. there are multiple words must be separate ‘_’
static final String FIRST_NAME="Kannan"
Advantages in Naming Convention in Java language
- Programmer make code easier to read for them self for other developers
- Readability and understandably is very easy
- Easy to find What the program does
Suggested for you
Class and main method in Java language
Data type and variable in Java
Feature of Java programming language
Flavour and versions of Java Programming language