3 ms·
please don't use java.lang.Integer unless you really have to. I know it's just an example but it gives the wrong ideas of what good code is. Each operation in
by xxs 10y ago
please don't use java.lang.Integer unless you really have to.
I know it's just an example but it gives the wrong ideas of what good code is.
Each operation in baz() consists of Integer.intValue() and Integer.valueOf(int), like
Integer inc = Integer.valueOf(2);
bar = Integer.valueOf(bar.intValue() + inc.intValue())
...
besides dealing with unneeded indirection values outside [-128 : 127] actually create an object that has to be allocated+GC'd each assignment.
Such nuances give Java the bad rap. 'int' maps straight to the hardware, java.lang.Integer - not so much.
- hnbroseph 10y agothis seems like a rather odd tangent.
- xxs 10y agoyou mean the syntactic sugar or the jab at java.lang.Integer? Flip note, the code would fail w/ NullPointerException if bar was not initiated (bar=0) but left null.
- _jal 10y agoThe jab at j.l.Integer. I have my pet annoyances, too, don't get me wrong. Just the other day, I saw someone in a coffee shop using 8-stop tabs and had to set them straight. They were in the middle of a conversation about food, but this is important.