When an object is created, it's necessary to call the constructors
of all super classes to initialize their fields.
Java does this automatically at the beginning
if you don't.
For example,
the first Point constructor
(see Constructors) could be be written
public Point(int xx, int yy) {
super(); // Automatically inserted
x = xx;
y = yy;
}
JFrame you might do the following.
class MyWindow extends JFrame {
. . .
//======== constructor
public MyWindow(String title) {
super(title);
. . .
In the above example you wanted to make use of the
JFrame constructor that takes a title as a parameter.
It would have been simple to let the default constructor
be called and use a setter method as an alternative.
class MyWindow extends JFrame {
. . .
//======== constructor
public MyWindow(String title) {
// Default superclass constructor call automatically inserted.
setTitle(title); // Calls method in superclass.
. . .
Point constructor
with no parameters? Altho the previous example
(see Constructors)
did define a parameterless constructor to illustrate
use of this, it probably isn't a good
idea for points.