Skip to content
Advertisement

Tag: lambda

Writing Content to a Text File with Currying

I’m trying to write to a text file using the above method by applying the concept of currying. The first lambda expression receives the file path as parameter and the second one takes in a String value that should be written to the text file. The write method receives a BiConsumer argument because data is written differently depending on the

Using a predefined lambda as an argument in Java [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 11 days ago. Improve this question So i’m trying to pass this test: I’m having a really hard time understanding how to create a method count that can take the lambda

Converting List to TreeMap java lambda

I’m trying to convert a List<String> to a TreeMap<Long, CustomClass> The key is the same as the list items but just parsed to Long, the value is just a call to new CustomClass(). How can I achieve this using lambda functions? the above code errors out, with the following error, Answer For example:

Java 8 reduce method calls depending on a value

How to optimize method that returns the first non empty value returned of the checkN() methods and prevent the rest method calls and isEmpty() calls: #1 I thought of using stream filter and return first that has value, but it requires to call each check: SOLVED as M A suggested, finalized solution for me was: Answer Instead of constructing a

Sorting an arraylist with lambda function isn’t working

I’m trying to use .sort() method with an arraylist. My method public void sortSurname() should sort alphabetically all the objects by their surname, these objects are contained in an arraylist ArrayList<Contact> contacts. Could someone please find the issue with this code? Here is what I’ve written so far: Contact class Rubrica class Main Thank you for the help. Answer The

Advertisement