• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Java lambda practice problems for learning and regular practice

 
Ranch Hand
Posts: 71
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone !

I am looking for two sets of practice problems to learn and remember Java lambdas. Can someone please suggest some decent resources for this ?

Set 1) The 1st set would have plenty of problems of beginner and expert level. It will help me to test myself after learning lambdas. I will use this only once or twice in life.

Set 2) The 2nd set will have a few problems which cover all features of lambdas. I will practice these every week/month just to remember the concepts. I'll do this for a year or so till I remember the concepts.

Thanks !

PS - I have read about lambdas in detail with a few examples about 3 times in 2 years or so. I never got a chance to practice them much and forgot everything each time. This time, I want to remember it well and avoid re-learning so many times.
 
Marshal
Posts: 67939
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I shall move you to the λs forum. Go through that forum and see if you can find any examples there.
I haven't seen a resource like what you described. Maybe, find a book like Modern Java in Action by Urma Fusco and Mycroft (older edition called Java8 in Action) because that has exampes of λs in.
 
Rancher
Posts: 107
19
Firefox Browser MySQL Database Java Ubuntu
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To gain experience with lambdas I like to do programming challenges like on Codewars or Exercism. I challenge myself to use streams wherever I can. It has really helped me.
 
Sheriff
Posts: 6801
182
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At Exercism you can look at how others solved the problem and often they use lambdas and streams in a way you hadn't thought of.
 
Jj Roberts
Rancher
Posts: 107
19
Firefox Browser MySQL Database Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:At Exercism you can look at how others solved the problem and often they use lambdas and streams in a way you hadn't thought of.

Yes, it is always good to be able to see different approaches to a problem. I actually learned about Exercism from a post of yours somewhere here on the Ranch . It's very slow — it sometimes takes a few weeks for a mentor to look at a solution — but it is great to be able to get feedback, both from mentors and other users.
 
Campbell Ritchie
Marshal
Posts: 67939
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jj Roberts wrote:. . . it sometimes takes a few weeks for a mentor to look at a solution . . .

We do occasionally manage a reply within the week here too, you know.
 
Tom Joe
Ranch Hand
Posts: 71
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jj Roberts wrote:To gain experience with lambdas I like to do programming challenges like on Codewars or Exercism. I challenge myself to use streams wherever I can. It has really helped me.


Thanks. Those look like very useful websites in general. But, I could not find any exercises on java lambdas in Exercism - https://exercism.io/tracks/java/exercises
or codewars. Do you know the location of the java lambda examples ?
 
Knute Snortum
Sheriff
Posts: 6801
182
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe for Codewars (and I know for Excercism ) that the challenges are not asking you to code a certain way.  These are just challenges with solutions that may or may not have lambdas or streams.  I sometimes challenged myself to redo a problem I already solved as a stream.  Looking at other people's solutions I found out how they used streams too.
 
Jj Roberts
Rancher
Posts: 107
19
Firefox Browser MySQL Database Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There aren't exercises specifically for lambdas, but I think that may actually make them more valuable for learning. Tackling realistic problems will teach you how to use streams and lambdas, but also when. You have to work out what approaches you are going to use.

[Edit] Most of the Exercism problems I have solved so far work well for streams and lambdas
 
Tom Joe
Ranch Hand
Posts: 71
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The links shared in this post are not particularly useful for structured study. The strategy - pick a project/sample code from somewhere and tinker helps when one already knows the basics of a topic, but not when someone is learning the basics and trying to remember things. I guess I'll have to continue searching and make a list myself.
 
Bartender
Posts: 3747
154
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As is written, if you have a solution to some problem, solved in java < 8, you can always try to rewrite it using lambda's.

But lambda's are not difficult. When I got maths for the first time, at high school, a function was written like this:  f: x -> x + 5. And from this, getting the corresponding lambda, is straight forward: x -> x + 5.

Tougher to grasp are method references. Whenever applicable, once you have a lambda, try to see if you can change that to a method reference.

But the greatest challenge is: mastering the methods in the Collectors API, where it all comes together. And that mastering took me a long time, with much blood, sweat and tears (and ugly words), but in the end, that's what you do it for!
 
Tom Joe
Ranch Hand
Posts: 71
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Piet Souris wrote:As is written, if you have a solution to some problem, solved in java < 8, you can always try to rewrite it using lambda's.

But lambda's are not difficult. When I got maths for the first time, at high school, a function was written like this:  f: x -> x + 5. And from this, getting the corresponding lambda, is straight forward: x -> x + 5.

Tougher to grasp are method references. Whenever applicable, once you have a lambda, try to see if you can change that to a method reference.

But the greatest challenge is: mastering the methods in the Collectors API, where it all comes together. And that mastering took me a long time, with much blood, sweat and tears (and ugly words), but in the end, that's what you do it for!



If you have mastered it, then I recommend making a book on just problems/exercises of different types. We could learn from you and you could also make some $$$
 
What are you doing? You are supposed to be reading this tiny ad!
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!