Java constants

  1. How to define constants in Java:

          final < type > constantName = constantValue

    The keyword final defines constants in Java.

    Each constant has a type !

    Constants must (like everything else) be contained in some class....

        class myClass
           final double PI = 3.14159265358979;
           final int DAYS_PER_YEAR = 365;

  2. To use the constant PI defined in the class myClass, you use:

    We have used constants defined in the wrapper classes before: Byte.MIN_VALUE ! ( click here)