Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c

Naming conventions in Java language

Posted on March 12, 2017September 15, 2019

Table of Contents

  • Naming conventions in java language
      • Naming convention

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

Related

Recent Posts

  • Subtract two numbers using method overriding
  • PHP Star triangle Pattern program
  • Using function or method to Write temperature conversion : Fahrenheit into Celsius
  • Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user
  • Write temperature conversion program: Fahrenheit into Celsius
  • How to write a program to convert Fahrenheit into Celsius

tag

Addition (6) Array (38) C++ language (91) C language (98) c sharp (23) Division (6) Function (29) if else (32) Java language (102) JavaScript (5) loops (137) Multiply (7) Oop (2) patterns (65) PHP (13) Python Language (38) Subtraction (7) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2025 Code for Java c | Powered by SuperbThemes