Naming Conventions

Basic Syntax

Naming Conventions

🙋 Need help? Ask an expert now!

When you begin writing your own Java programs, there are some naming conventions that are strongly suggested. These naming conventions make it easier to understand what the program does, gives information about the identifiers and helps you understand the code. Please take a look at the code below for some examples of naming conventions for identifiers.
package exlcode;

// class names are written in UpperCamelCase
// class names are usually nouns or noun phrases.
public class NamingConventionsExample {

  // constant names are written with all upper case
  // letters with words separated by underscores
  public static final int EXAMPLE_VARIABLE_ONE = 10;
  // non-constant field names are written with lowerCamelCase
  // variable names must be specific and meaningful
  public static int exampleVariableTwo = 5;
  // names like "string1, myarray1, no_1" are not acceptable
  // as variable names because they are are not specific
  // and can cause confusion like the variable below:
  public static String string = "String";

  public static void main(String[] args) {
    // local variable names are written in lowerCamelCase
    int exampleVariableThree = 15;
    printGreeting("Hello World!");

  // method names are written in lowerCamelCase
  // method names are usually verbs or verb phrase
  // parameters names are written in lowerCamelCase
  public static void printGreeting(String parameterOne){

Let's review three common naming conventions of which examples can be found in the code. Moving forward, let us remember and implement the following naming conventions.

  1. lowerCamelCase:

    Name is formed with multiple words that are joined together as a single word, with the first letter of each of the multiple words (except the first one) capitalized. Used for method names, non-constant field names, and parameter names.

  2. UpperCamelCase:

    Name is formed of multiple words that are joined together as a single word, with the first letter of each of the multiple words capitalized. Used for class names.


    Name is formed with every letter of each word in uppercase letters, with words separated by underscores. Only used for constants. (We will learn about constants later in the course.)

Edit Me on GitHub!

Application Question

Which one of the choices accurately implements UpperCamelCase?