Forum Stats

  • 3,875,465 Users
  • 2,266,926 Discussions


How can I supress nested class's dominancy over "import"?

HopeSpartan Member Posts: 2 Green Ribbon

Error : Type mismatch cannot convert from Double to Rectangle2D.Double

I am using Eclipse Oxygen.3a Release (4.7.3a) and it gives a error when I define a java.lang.Double variable inside a class which extends java.awt.Rectangle ((i.e. serializable class).

Repeating steps for getting a this error :

1. Create a class extends java.awt.Rectangle (public class Collidable extends java.awt.Rectangle)

2. Create a private java.lang.Double variable (private Double speed)

3. Create getter and setter to a variable created in step 2 (getSpeed() )

4.Create another class which does not extend any class and publish a java.lang.Double type variable (public class Vector2D() and private Double length).

5.Create an instance of the class at step 4 inside class created in step 1( in Collidable class : private Vector2D velocity and set speed to its length and this.speed=getVelocity.length(); )

6.You will end up an error : "Type mismatch : can not convert from Double to Rectangle2D.Double" error.

When I just define all variables haveing Double as java.lang.Double in Collidable class and problem will be solved ,error disappears.

I report it as but in :

But two person whose names are both "Thomas" say that it is not a bug since java compiler gives error too.

I changed my question to that : how can I supress nested class's dominancy ? In other words : how can I make "Import" reserved word supress nested class's dominancy ?