One of the nice things I like about the new Java 8 lambdas is that I can encapsulate common code inside a method. So if code inside the doPrintln() method is an algorithm or a test that needs to call common code multiple times as represented by the myFunc1 lambda, we don’t need to bring that logic outside the method by creating a separate private method. We can maintain DRY (“do not repeat yourself”) code by using a lambda.
By combining the power of generics and varargs, I’m able to have a lambda take a variable number of arguments of any type. This reminds me a lot of some Scala code I’ve seen and used. I’ve also done something similar using C# func delegates.
I think larger methods with lambdas inside are a better design practice and increase readability. When your eyes come upon a class for the first time, the private methods don’t cloud things by requiring one to figure out how many other methods are using the private one. Yes, a few clicks in an IDE will tell you, but this is one less step to get you there. This is an excellent way to implement method or function cohesion.