Naming conventions in Java language

Naming conventions in java language

In this tutorial, we will dsicuss the concept of Naming conventions in java language

What is the naming conventions in java?

Naming conventions is set of rules to follow as you decide what do you to name your identifier such as Class, Packages, Variable, Constant, methods etc.. ,

When Say in other words,  a set of rules how to named variables, Methods, Class, Packages, Constants that make life of progrmmers easier

Naming convention makes program more easily understandablity and readablity

All names must start with a letter(A to Z or a to z) or an underscore( _ ) or $

Legal names
myname, myName, _special, $MySalary

illegal names
2person, -mysalary, %Duty, @Myname

Never use spaces in the names of things

A space means a new command or a character

legal names
MyName – No space this is legal
This_is_java – No space this is legal

illegal names

My name, This is wrong

Java names may contains

Letter, numbers, Underscore ( _ ) or $ sign

Legal names
Employeedetails10, School_name

Illegal_Names
owner#age,  My@home, best-prize

Naming convention

Package
package name is always written in all lower case letters
java, lang,util

Classes
class name should be noun, in mixed case with the first letter of internal word capitalized – uppercase
eg -Myclass, First, HelloWorld,Patient

Interface
Interface names should be  capitalized looks like class name
Interfaces should be an ajective
eg – Runable, understandable

Methods
Methods should be verb, in mixed case with the first letter lower case and with the first letter of each internal words capitalized
eg – run(), print(), display()

Variables
variable may contain letter and digits drawn from the entire characterset
variable name should start with a lowercase letter. and New word in a name start with the upper case letter
eg .hello, variable, myName, calculate
variables should be self – describing
Variable should be camel case

Contants name
Constants names made up of all uppercase letter with underscores to separate words
eg – PI, MAX_Prize

Karmehavannan

Recent Posts

Using function or method to Write temperature conversion : Fahrenheit into Celsius

Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…

11 months ago

Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user

Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…

11 months ago

Write temperature conversion program: Fahrenheit into Celsius

Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…

11 months ago

How to write a program to convert Fahrenheit into Celsius

How to write a program to convert Fahrenheit into Celsius In this article, we will…

11 months ago

Function/method to convert Celsius into Fahrenheit -Entered by user

Function/method to convert Celsius into Fahrenheit -Entered by user In this article, we will discuss…

11 months ago

Temperature conversion: Celsius into Fahrenheit using function or method

Temperature conversion: Celsius into Fahrenheit using a function or method In this article, we will…

11 months ago

This website uses cookies.