I was recently debugging a problem where a result was much larger than expected. What I had intended to write was:
y += height + rowHeight * 2;
What I had written was
y += height * + rowHeight * 2;
I didn’t see the error right away because, apparently * + is a valid operator in Java, or at least Android java. I’ve never heard anything about this before, and I have no idea what it means.
As an experiment, I found that the generalized form of this is, as a regex [*/%][+-]*
It looks like some form of polish notation, but I was unaware that Java supported such.
So… where would I find documentation about this operator, and what, exactly, does it mean?
It’s using the unary plus operator – so it’s like this:
To give an example which wouldn’t look odd at all, but using unary minus instead of unary plus:
Hopefully that makes more sense 🙂