Math
fields for common mathematical constants
-
Math.PI
(3.141592653589793)
-
Math.E
(2.718281828459045)
Declared in class
Math
with the modifiers
public,
final
and
static
-
public
allows
you to use these fields in your own classes.
- A
field declared with keyword
final
is constant—its value cannot change after the field is initialized.
- PI
and
E
are declared
final
because their values never change.
- A
field that represents an attribute is also known as an instance variable—each
object (instance) of the class has a separate instance of the variable in
memory.
-
Fields for which each object of a class does not have a separate instance of
the field are declared
static
and are also known as
class
variables.
-
All objects of a class containing
static
fields share one copy of those fields.
-
Together the class variables (i.e.,
static
variables) and instance variables represent the fields of a class.
Click here for more information on static field.
Click
here for more information on final.