• Post Reply Bookmark Topic Watch Topic
  • New Topic

Lambda / predicate  RSS feed

 
Laimonas Oberauskis
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi folks, above is a perfectly working code. However, I would like to know how does one write the line "check(animalList, a -> a.isPurrer());" with full lambda signature (signature blueprint is like this: (Animal a) -> { return a.canHop(); } ).
And one more question, how often are lambdas and predicates used in a real life coding?
Thanks in advance!
 
Campbell Ritchie
Sheriff
Posts: 54078
130
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you seen the details of the Stream#filter() method, the Predicate interface and the appropriate part of the Java™ Tutorials about nested classes? You might only need the last link.
You end up with something like
 
Campbell Ritchie
Sheriff
Posts: 54078
130
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can probably condense that Predicate to a method reference.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!