Created
January 20, 2013 21:17
-
-
Save futjikato/4581836 to your computer and use it in GitHub Desktop.
Beispiel fü statisches binden von Eigenschaften in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Counter { | |
protected int c = 0; | |
public void increase() { | |
c++; | |
} | |
} | |
class LimitedCounter { | |
protected int c = 0; // Dise variable "überschattet" c aus der Superklasse | |
protected int limit = 10; | |
@Override | |
public void increase() { | |
super.increase(); | |
if(c > limit) { // Das hier wird niemals erfüllt sein, da Eigenschaften statisch gebunden werden | |
c = 0; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment