Java - Constant

Java Conceptuel Diagram

About

The names of constant fields are in upper-case letters.

By convention, the names of constant values are spelled in uppercase letters. If the name is composed of more than one word, the words are separated by an underscore (_).

Implementation

static final

You can create a class variable A constant member is defined with the modifier static and final.

final class Constants {

    static final char BACKSPACE = '\b';
    static final char COMMA = ',';
    ....
}

And import it in your other class, if you don't want to use the qualified name:

import static gerardnico.Constants.*;

enum

See Java - Enum datatype





Discover More
Java Conceptuel Diagram
Java - Class Variable (Static Fields)

A class variable is any field declared with the modifier static. A field defining the number of gears for a particular kind of bicycle could be marked as static since conceptually the same number...
Java Conceptuel Diagram
Java - Enum datatype

The enum data type implementation in java Because they are constants, the names of an enum type's fields are in uppercase letters. The enum declaration defines a class (called an enum type). The enum...
Java Conceptuel Diagram
Java - Static Modifier

in Java. The Java programming language supports static methods. Static methods, which have the static modifier in their declarations, should be invoked with the class name, without the need for...



Share this page:
Follow us:
Task Runner