I was wondering if it's possible to define a method within the implementation of an interface class and call that method from another class?
for example:
public interface MyInterface
{
void method1();
}
public class MyClass1 implements MyInterface
{
public void method1()
{
System.out.println("This is already defined in MyInterface")
}
public void method2()
{
System.out.println("This is not already defined in MyInterface")
}
}
public class MyClass2
{
public static void main(String[] args) {
{
MyInterface interface = new MyClass1()
interface.method2
}
}