What is the purpose of Java's unary plus operator?
- by Syntactic
Java's unary plus operator appears to have come over from C, via C++. As near as I can tell, it has the following effects:
promotes its operand to int, if it's not already an int or wider
unboxes its operand, if it's a wrapper object
complicates slightly the parsing of evil expressions containing large numbers of consecutive plus signs
It seems to me that there are better (or, at least, clearer) ways to do all of these things.
In this SO question, concerning the counterpart operator in C#, someone said that "It's there to be overloaded if you feel the need." But in Java, one cannot overload any operator. So does this operator exist in Java just because it existed in C++?