I want to convert a LambdaExpression like
pos -> pos.x < 5 && pos.y < 5 to a String which looks like this:
"pos.x < 5 && pos.y < 5"
Is this possible in Java?
In C# I’m using something similar like this
No, it’s not possible.
Java is compiled to a set of bytecode instructions. The exact form of all Java source code, including that of lambdas, is lost at the point of compilation. It is a one-way process; certain details are irretrievably discarded (whitespace being one example, but there are other, less trivial ones) so you cannot recreate the source code from bytecode.