Skip to content

Instantly share code, notes, and snippets.

@RuZman
Created April 2, 2015 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RuZman/eee0b531981896bcbb5b to your computer and use it in GitHub Desktop.
Save RuZman/eee0b531981896bcbb5b to your computer and use it in GitHub Desktop.
public class SubClass extends AClass {
public static void main(String[] args) {
System.out.println(new SubClass(6).getValue1());
}
public SubClass(final int value) {
super(new ICalc() {
@Override
public int getValue() {
return value + 10;
}
});
}
}
abstract class AClass {
private final int value1;
public AClass(ICalc calc) {
this.value1 = Objects.requireNonNull(calc.getValue());
}
public final int getValue1() {
return value1;
}
}
interface ICalc {
int getValue();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment