Top community members
All Wiki Articles Create Wiki Article

Welcome to Dirask IT community! ❤ 💻
We are community that shares solutions with each other.

If you think you have something to add here.

you are welcome with your fresh ideas - List Articles

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

0 contributions
5 points

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
0 contributions

Checkout latest Findings & News:

Checkout latest questions:

Checkout latest wiki articles:

Hey 👋
Would you like to know what we do?
  • Dirask is IT community, where we share coding knowledge and help each other to solve coding problems.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.
Read more