[Solved] Java – Can I concatenate a String with a lambda? How?


yshavit:

What you’re trying to do isn’t easy/natural to do in Java. You’re basically trying to write an expression which creates and immediately invokes a method, basically as a way of grouping a bunch of statements together (and also providing an enclosed scope) to get a single value. It’s not an unreasonable thing, and in JavaScript it’d be possible (and I think it’s even considered decent style, though I’m not sure about that). But Java isn’t set up for that. Your best option would be to create a real, non-lambda function for that try block. (Bonus: it’ll be less indented, so easier to read.)

solves my question

solved Java – Can I concatenate a String with a lambda? How?