Hi is something like this possible in Java?
boolean flag = true;
if(flag) return flag = false; // return true and assign false to flag afterwards
No, there isn't a way to do that.
Why not?
Well you would need to ask the Java language designers for the real answer, but I imagine that they would have dismissed such a proposal out of hand. Java is designed to be a language that is easy to learn, read and understand. Adding operators that are designed to do "clever" things in a concise way is liable to make the language harder to learn, and harder to read ... for the average programmer. And, if the operator is only really useful in a tiny number of use-cases, that makes the readability versus utility argument even harder to win.
Also, adding new features to Java is often more technically difficult than you would imagine because of interactions with other (existing) language features.
And actually, there is precedent to back this up. One of the Java 7 / 8 revision proposals in Project Coin was to add an elvis operator to Java. The proposal was considered ... and ultimately dismissed.