Section 3.7 Naming Conventions
It is worth pointing out that Java has some very handy naming conventions. It is advisable to both use meaningful names and to follow these naming conventions while developing software in Java for good maintenance and readability of code.
-
Class names should be nouns that are written in UpperCamelCase, namely with the first letter of each word capitalized including the first. For example,
ArrayList,Scanner,StringBuilder,System, etc. -
Method names use lowerCamelCase which start with a verb that describes the action they perform. This means that method names start with a lower case letter, and use upper case for each internal-word method names. For example,
isInt(),nextLine(),getDenominator(),setNumerator(), etc. -
Instance variables of a class start with a lower case letter and use lowerCamelCase like method names. For example,
count,totalAmount, etc. -
Constants are in all upper case letters or in upper snake case, which also known as screaming snake case, and which is a naming convention in which each word is written in uppercase letters, separated by underscores. For example,
Math.MAXINTorMAX_INT.
You have attempted of activities on this page.
