Java Names Convensions
Java Names Convensions
Java Names Convensions
Overview
Today we will discuss:
Reasons for naming conventions
Rules for naming variables, classes, and methods
During debugging
When adding to the program
When updating the program
When trying to understand the program
Naming classes
Rule 18: Capitalize the first letter of each word,
including the first:
PrintStream, Person, ExemptEmployee
Rule 19: Use nouns to name classes:
ExemptEmployee, CustomerAccount
Classes are supposed to represent things
Naming variables
Rule 25: Capitalize the first letter of each word
except the first:
total, maxValue
Rule 26: Use nouns to name variables:
balance, outputLine
Variables are supposed to represent values
Naming methods
Rule 22: Capitalize the first letter of each word
except the first:
display, displayImage
Methods are capitalized the same as variables
Naming constants
A constant is an identifier whose value, once given, cannot be
changed
Constants are written with the keyword final, for example:
final int FIVE = 5;
final float AVOGADROS_NUMBER = 6.022E23;
The End