If I have:
public class MyClass{
MyClass(Object b){
//Some code here
}
}
And I do:
MyClass X = new MyClass(new SomeOtherClass());
It works just fine, im assuming, because every class has Object as a superclass.
But, if I do:
import java.util.function.Predicate;
public class MyClass{
MyClass(Predicate<Object> b){
//Some more code here
}
}
And then:
MyClass X = new MyClass((SomeOtherClass s) -> {
//Even more code
return true;
});
I get an error saying:
Incompatible parameter types in lambda expression: expected Object but found SomeOtherClass
Shouldn't I be able to send a SomeOtherClass
object in that lambda expression?
I'm using the Object
class because i wanna be able to recieve not only SomeOtherClass
, but also SomeOtherClassXPTO
.
I tried looking this up and found nothing so far, so my apologies in advance if this has been asked before.