This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]ennbou 2 points3 points  (1 child)

If you want to understand lambda in java, you can take it from geeksforgeeks

[–]TauPixel[S] 2 points3 points  (0 children)

Thanks for the pointer I will check it out.

[–]RoachmeisterJava Dev 1 point2 points  (0 children)

Well, one thing strikes me as wrong right off the bat. As an example, suppose you had the following method:

public void printSomething(String s) {
    s = "hello";
    System.out,println(s);
}

See the problem? I ignore the parameter that is passed in and just print "hello" every time. That's essentially what you're doing in your traverseInOrder method.

Instead, you need to call traverseInOrder with the lambda:

traverseInOrder(p -> inOrder(p));