I am playing around with the new Lambdas in Java 8 in Android Studio and attempting to utilize the below line:
public Contact findContactByCode(String ContactCode) {
return this.list.stream().filter(o -> o.getType().getCode() == ContactCode).collect(Collectors.toList());
}
The list object is a generic ArrayList, for which the generic type has been assigned to the Contact Model. Everything is good until I get to the collection function and that is where I am getting the below error:
"no instance of variable T exists so that List< T > conforms to Contact, inference variable R has incompatible bounds: Equality constraints: List< T >, Upper bounds: Object, Contact"
Everything that I am seeing looks correct, but I am not quite sure what is going wrong.
You are attempting to return a List, but the method declaration calls for returning a Contact. Change one of those and you should be fine
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.