Created
April 2, 2015 19:45
-
-
Save RuZman/eee0b531981896bcbb5b to your computer and use it in GitHub Desktop.
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
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