Skip to content

Instantly share code, notes, and snippets.

@futjikato
Created January 20, 2013 21:17
Show Gist options
  • Save futjikato/4581836 to your computer and use it in GitHub Desktop.
Save futjikato/4581836 to your computer and use it in GitHub Desktop.
Beispiel fü statisches binden von Eigenschaften in Java
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