TL;TD In Java 8, is there a way for an interface default method to access instance variables?
For instance:
public interface Foo{
default getBazModified(){
return baz * 2;
}
}
public class Bar implements Foo {
int baz;
...
}
I know that sounds like travisty but is there a way to do anything like that in Java 8?
Or is the only way is to have an abstract class that implements Foo, which would have both the instance variable baz declared and have a default implementation of getBazModified()?