# Naming convention in Java

In 
Published 2022-12-23

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.

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.