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
    • Related

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

  • Multiply two numbers in Java using scanner| 5 different ways
  • 5 different ways to Divide two numbers in Java using scanner
  • Learn 8 Ways to Subtract Two Numbers Using Methods in Java
  • 10 ways to subtract two numbers in Java
  • Java Code Examples – Multiply Two Numbers in 5 Easy Ways
  • How to Divide two numbers in Java| 5 different ways

tag

Addition (8) Array (38) C++ language (91) C language (98) c sharp (23) Division (8) Function (29) if else (32) Java language (108) JavaScript (5) loops (138) Multiply (8) Oop (2) patterns (66) PHP (13) Python Language (38) Subtraction (9) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2026 Code for Java c | Powered by SuperbThemes