Languages
[Edit]
EN

Java naming convention - static final class fields - private and public

5 points
Created by:
Flimzy
596

1. Overview

All static final class fields in java should be upper case with underscore between words.

2. Sun Microsystems PDF - Java Coding Style Guide

3.3 Field naming
Names of fields being used as constants should be all upper-case, with underscores separating words.
The following are considered to be constants:

  1. All static final primitive types (Remember that all interface fields are inherently static final).
  2. All static final object reference types that are never followed by "." (dot).
  3. All static final arrays that are never followed by "[" (dot).

Examples:

  • MIN_VALUE,
  • MAX_BUFFER_SIZE,
  • OPTIONS_FILE_NAME

Achut Reddy - Server Management Tools Group - Sun Microsystems

Links to this pdf:

3. JDK examples

// java.lang.Boolean
public static final Boolean TRUE = new Boolean(true);
public static final Boolean FALSE = new Boolean(false);
// public static final Class<Boolean> TYPE = (Class<Boolean>) Class.getPrimitiveClass("boolean");

// java.lang.Math
public static final double E = 2.7182818284590452354;
public static final double PI = 3.14159265358979323846;

// java.lang.Character
public static final int MIN_RADIX = 2;
public static final int MAX_RADIX = 36;

References

  1. Naming convention - wiki
  2. Naming convention Java - wiki
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Java - conventions, naming, best practices

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join