> The class Line2D.Float overrides that method with
> float return type and Line2D.Double with double
> return type.
Overriding a method with a different return type does not work in
Java. I'm not sure what you are referring to. The Float subclasses
override the accessors to return their values promoted to the
common return type, but they do not change the return type itself.
> But... why and abstract class and two other classes?
> Why not only a double version?
The Float class takes half the space of the Double version, but
it also has correspondingly less precision and range as a result.
Your code can choose whether or not you want to waste the space
for double storage or not. For an isolated object, the difference
isn't significant. But, if you have an array of these or if you
generate a lot of the objects on the fly during a particular
algorithm (one might question whether such an algorithm should
not be recoded to create less garbage, though), then the size of
the storage starts to matter.
The abstract superclass allows for lots of different implementations,
not just the simple-minded ones that we include. It could represent
a "live view" of a point or line/curve segment in a more complex data
structure. Or it could represent a constant value (of questionable
taste since the standard 2D abstract superclasses all act as if they
should be editable - you would have to throw exceptions on those
methods which might surprise some calling code...)
...jim
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 2D Home Page: http://java.sun.com/products/java-media/2D/