vlad321 said:
Static is not scope. It has nothign to do with restrictions from where a variable is visible. |
Static variables are bound to a class and not an object instance. In this compilation error, it is most likely referring to the SpaceShip.x and SpaceShip.y. SpaceShip is the name of the class and it is expecting there to be x and y static variables in the class. But without more code to look at, it is hard to tell. Here is most likely what he did.
public class Bullet extends Body{
public Double x;
public Double y;
public Double xVelocity = x - SpaceShip.x;
public Double yVelocity = y - SpaceShip.y;
...
...
In which case SpaceShip does not have static variables with this name.
Java does not have a global scope but static variables are as close as it gets. There is only one instance of each static variable per ClassLoader(A JVM can have more than one class loader). But you are correct in that static does not define visibility.







