I may be having it wrong but i am getting an error with an Optional<>
as method argument in Java.
I have an interface:
public interface FooInterface;
And a class that implements it
public class Foo implements FooInterface;
Now, suppose i have a method that receives an Optional<FooInterface>
someMethod(Optional<FooInterface> arg)
I get an error if i do this:
Optional<Foo> foo = Optional.of(new Foo());
someMethod(foo);
It says that Optional<FooInterface>
is expected instead of Optional<Foo>
.
Why is that?