Java Naming Conventions

Java has some very straightforward naming conventions. These are universally used by Java programmers, and differ in some cases from conventions commonly used in other languages.

Again, these are conventions. Ignoring them will not prevent your code from running, as long as you are following Java’s naming rules . Java’s identifier naming rules are somewhat hard to parse, so a good rule-of-thumb is that you should use only letters, numbers, and the underscore character _, and they should always start with a letter.

The naming conventions are more like guidelines than rules and are what other Java coders expect to see when reading your code.

Identifier TypeConventionExamples
PackageAll lowercasedemos.javawebdevelopment, org.launchcode.utilities
ClassStart with an uppercase letterScanner, System, Cello
MethodStart with a lower case letter, and use camelCase to represent multi-word method namesnextInt(), getId()
Instance variableStart with a lowercase letter and use camelCaseid, firstName
ConstantAll uppercase letters, words separated by underscoresMAX_INT

Constants in Java are variables created using both static and final modifiers. For example: static final Double PI = 3.14159


If you’re not sure about all of these identifier types yet, that’s ok. Keep this page in mind for future reference as you read through this book.

Oracle, the company that develops the Java language, provides some more detailed naming conventions . (From the date on this article, you’ll note that these have been relatively standard for a very long time!)