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.
collect()to?Contactis not aList. Change the method to returnList<Contact>