I looked at the code of a colleague. She left it by accident (it was a string concatenation), and I assumed that it would not compile. It turns out I was wrong, so I tried to see what this operator did:
public static void main(String[] args) {
int i = -1;
System.out.println(String.format("%s", +i));
System.out.println(String.format("%s", +i));
}
As far as I can tell, he is not doing anything, but I am curious if there is a reason this is allowed to compile. Is there any hidden functionality for this operator? It is similar to ++i, but you might think that the compiler will be tagged +i.
source
share