Suppose I have an abstract class Game:
public abstract class Game { public static final int FRAME_LENGTH = 40; public static int getFrameLength() { return Game.FRAME_LENGTH; //What do I have to replace Game with? } } And there is the class App which extends Game:
public class App extends Game { private static final int FRAME_LENGTH = 50; } Now, when the method App.main() is executed, it prints 40, I would have expected 50, as App has overwritten the value of FRAME_LENGTH. I guess I would have to use something like self in the Game class, except java has no self.
How am I supposed to access the static property App.FRAME_LENGTH without knowing beforehand that the child class will be called App?
Edit
Okay, based on the first answer, I think I have to specify my question a little.
First, I change the scope of FRAME_LENGTH to public. For the sake of this question, this makes things easier. Second, I changed the method getFrameLength which was previously called main.
The problem I am facing: Right now, I do not know which classes will extend Game, and Game should not need to know, either.
If you look at the code, you will be able to see that Game.FRAME_LENGTH is 40 and App.FRAME_LENGTH is 50. Game.getFrameLength() returns 40 as expected, but App.getFrameLength() returns 50, I would expect (or rather want) it to return 50.
My question now is very simple: In the above code, what do I have to change return Game.FRAME_LENGTH; to, so it returns the correct value (meaning the value of FRAME_LENGTH of the class the method is called on), similar to self::$frameLength in PHP.