Using static to declare constants

suggest change

As the static keyword is used for accessing fields and methods without an instantiated class, it can be used to declare constants for use in other classes. These variables will remain constant across every instantiation of the class. By convention, static variables are always ALL_CAPS and use underscores rather than camel case. ex:

static E STATIC_VARIABLE_NAME

As constants cannot change, static can also be used with the final modifier:

For example, to define the mathematical constant of pi:

public class MathUtilities {
    
    static final double PI = 3.14159265358

}

Which can be used in any class as a constant, for example:

public class MathCalculations {
   
    //Calculates the circumference of a circle
    public double calculateCircumference(double radius) {
        return (2 * radius * MathUtilities.PI);
    }

}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


static keyword:
* Using static to declare constants

Table Of Contents
8 Arrays
10 Maps
11 Strings
25 JAXB
29 Enums
32 Audio
41 Scanner
63 Logging
64 static keyword
75 Lists
78 Sets
89 JAX-WS
96 XJC
98 Process
106 Modules
114 Applets
122 JNDI
139 JavaBean
141 Literals
144 Packages
150 JMX
153 JShell
159 Sockets
167 Enum Map
175 Hashtable
177 SortedMap