#
Naming convention in Java
This tutorial explains to you which are the Java naming conventions.
For a better read and understanding of Java code we have to follow the following conventions. This is not mandatory, but it is a good approach.
Info
- Camel Case syntax: numberOfOrders
- Pascal Case syntax: NumberOfOrders
- Kebab Case syntax: number-of-orders
- Snake Case syntax: number_of_orders
- Flat Case syntax: numberoforders
- Upper Flat Case syntax: NUMBEROFORDERS
class naming in Java
Convention:
- start with uppercase letter
- be a noun
- follows the PascalCase syntax.
Examples: String, MountainBike, Color, Button, System, Thread, etc.
method naming in Java
Convention:
- start with lowercase letter
- be a verb
- follows the CamelCase syntax
Examples: main(), print(), actionPerformed(), startProcessing(), println(), etc.
interface naming in Java
Convention:
- start with uppercase letter
- be an adjective
- follows the PascalCase syntax
Examples: Runnable, Printable, Remote, ActionListener, etc.
variable naming in Java
Convention:
- start with lowercase letter
- be a noun
- follows the CamelCase syntax
Examples: string, mountainBike, color, button, system, thread, etc.
package naming in Java
Convention:
- start with lowercase letter
Examples: com, org, org.interfaces, java, lang, util, etc
constants naming in Java
Convention:
- are in uppercase
Examples: MAX_NUMBER, RED, FILE_PATH, etc.