I know that I can pass an interface
as an argument. Since we cannot create an object from an interface
! Can I create an object from a class
that extends
this interface
then I use this object in the place where I use this interface
as an argument?
My question, since obj
is an object from Final
class, can I use it as a parameter here (m1(obj)
)? And explain to me why, please?
package aaa;
public class AAA {
public static void m1(One one) {
System.out.print("AAA");
}
public static void main(String[] args) {
Final obj = new Final();
m1(obj);
}
}
interface One {
}
class Final implements One {
}