Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

How to Learn to Use Lambdas?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My immediate goal is to learn enough about lambda functions to get questions about that right on the Java 8 certification exam.  But I'm also interested in going deeper and learning languages of the LISP family (which I've been exposed to while trying to learn more about NLP/AI and about computer science courses in "advanced programming languages", and the like).  

How do you suggest getting a preliminary handle on using lambda functions?

Thanks.
 
Marshal
Posts: 8885
638
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, a warm welcome to the Ranch.

What's regarding Lambdas in OCAJP 8 certification - there isn't much. And these questions are, how to say, about syntax things more, than about lambdas as such. Not saying you shouldn't learn that, but don't put your all money on red when play roulette.

I believe in a book if you'd read very carefully you could find most likely those things explained when you can avoid enclosing argument in parentheses, when you cannot, when braces are needed, when not - so the questions in exam as far as I remember are more from that perspective. But consult with more resources as I don't remember everything by heart.

The rest of it, I'd rather leave to Author to comment.
 
Bartender
Posts: 2911
150
Google Web Toolkit Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The key to learning any concept in programming is by starting to write short examples and see how they work. You can refer to books and online tutorials, but your own experience will teach you better.
It's never too late to read the original java tutorials: https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html
 
Author
Posts: 161
31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lee,

If you goal is to pass the Java 8 certification exam, the official Java tutorial is certainly were you should start, although as Liutauras said, you will not learn about all possible use cases of lambdas. Probably not more that 20% of what can be done. (And possibly 80% of the syntax). This means how to use lambdas in imperative programming. Lambdas were probably not added to Java 8 in an attempt to make it a functional language. Some features have even existed during development of Java 8 and have been removed from the final version.

There are however some use cases that often occur in functional programming and nearly never in imperative programming. One example is a lambda returning a lambda, which is used for currying. Other special use cases involve specific handling of closures, or the possibility to create recursive lambdas. There are also some tricky way to handle type inference, and much more. All these specific uses are absent from the official tutorial (and are not needed for the certification). If you are interested, you can read a book specifically about lambdas. In my book, all these use cases are explained when they are needed. But once again, this is probably not very useful for the certification.
 
reply
    Bookmark Topic Watch Topic
  • New Topic