I have an interface and a class implementing it:
public interface IFoo{
Integer bar();
}
public class Foo implements IFoo{
@Override
public Integer bar(){
return 42;
}
}
Now in another class, I have a function which takes an ArrayList of the interface type.
public class Something {
public static void function(ArrayList<IFoo> foos){
//do something on foos
}
}
I want to use this function on an array list of Foo:
ArrayList<Foo> myFoos = new ArrayList<Foo>();
Something.function(myFoos);//can NOT do this
What is the problem or what shall I do?