|
Creating and Using Objects
An Introduction with Examples in Java |
|
Prof. David Bernstein
|
| Computer Science Department |
| bernstdh@jmu.edu |
boolean, double, int,...
new operator (which is a unary operator that has a
constructor as its operand))
null
(and is a reference/address that isn't valid)null
null will result in a run-time error
called a NullPointerException
== operator.equals() method
Rectangle and Frame are
classes of mutable objects)String and Color are
both classes of immutable objects)
public attributes (but they are very dangerous
since there is no control over the changes that can be made)
set (and, hence, are often
called setters)
increaseBy())
Color class has a
darker() method that doesn't change the
owning object but returns another Color
object that is "darker")