I have a class which implements an interface, but has a couple of extra methods. I can't edit the interface to add any extra methods and one of the methods of that interface returns a type of the interface itself.
public interface ExampleInterface{
public ExampleInterface method1();
}
The class has an extra method I wish to use which will print the contents of the class.
public class ExampleInterfaceImpl implements ExampleInterface {
public ExampleInterface method1() {
//method code
}
public void print() {
//print method code
}
}
So my question is if i have an object of type ExampleInterface, i.e. what is returned by method1(), and I then want to print it using print(), how can that be done seeing that print() is in ExampleInterfaceImpl so can't be called on an object of type ExampleInterface.