Emilian Chmiel wrote:
data is a
point1D[], so obviously you can get
point1D objects out of it. You can fill it with
point2D objects as well, because
point2D extends
point1D.
Emilian Chmiel wrote:
Protected access is less restrictive than default access. If your classes are all in the same package, they can access each other's protected members.
Emilian Chmiel wrote:
You can't change the type of variables once they are declared. Casting only allows you to treat a reference to an object as if it's a reference to a more specific type.
A few other remarks:
Don't put block statements on one line. Each statement within a block should be on their own line.Package names should start with a lower case letter.Class names should start with a upper case letter.Variable names should start with a lower case letter.You don't have to call super() in constructors, it's implicit.You don't have to initialize non-final numeric fields to 0, it's done automatically.Use the @Override notation when overriding a method.
Here's an example: