Java 8 introduced "default method" which allows describing the method's body.
I want to create one Interface and two child classes. In the Interface URL I'd like to have getURL() method:
public interface URL {
int getURL() {
return this.myURL;
} // obviously
}
and in two child classes I'd like to define the myURL field:
public class MyURL1 implements URL {
private String myURL = "http://test1.com";
}
public class MyURL2 implements URL {
private String myURL = "http://test2.com";
}
which will be returned by getURL.
Is it possible in Java?