Fifth International World Wide Web Conference
Java Class Example: Notes
- Note that variables of the type of a class are also just references
- Actual object only comes into existence when allocated via the
new
statement
- A class variable declared with the
static
modifier has only
one copy of the variable
- A class method declared with the
static
modifier is invoked
without reference to a particular object
- May only reference other
static
variables and methods in the
class
- Each variable or method specifies its own visibility rules:
- public
- accessible to anyone
- protected
- accessible only to class and other derived classes
- private
- accessible only to class
- (default)
- accessible to any class in the same package as the defining class
Java - An Introductory Language Tutorial
(E.A.Johnson)