interface ITest{} class MyClass{} class Main { public static void main(String[] args) { MyClass obj = new MyClass(); ITest iObj = (ITest)obj; //compiles fine --Line 2 SomeMethod(obj); // compile time error --Line 3 } public static void SomeMethod(ITest test) {} }
MyClass
ITest
interface ITest{} class MyClass{} class Main { public static void main(String[] args) { MyClass obj = new MyClass(); ITest iObj = (ITest)obj; //compiles fine --Line 2 SomeMethod(obj); // compile time error --Line 3 //you have pass obj rather than Iobj // try this SomeMethod(IObj); } public static void SomeMethod(ITest test) {} }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)