1 minute read

It is a good practice to follow a consistent naming approach in coding. Below is a set of conventions for naming classes, properties, methods and other elements in Java.

Element Naming Convention
class name begin with uppercase letter and be a noun e.g. Triangle, String, Color, Button, System etc.
interface name begin with uppercase letter and be an adjective e.g. Runnable, ActionListener etc.
method name begin with lowercase letter and be a verb e.g. allPositive, actionPerformed(), main(), sort(), println() etc.
variable name begin with lowercase letter e.g. a, b, lastName, appointmentNumber etc.
package name should be in lowercase letter e.g. mytools, java, lang, sql, util etc.
constants name should be in uppercase letter. e.g. GREEN, BLUE, MAX_PRIORITY etc.
{:.mbtablestyle}
comments powered by Disqus