374 plus ones
Shared publicly•View activity
View 43 previous comments
I just tested if Java would allow this, at least it wouldn't on the framework, the security manager prevents tampering.
(I tried to set the Integer.MAX_VALUE to 100 :P)Feb 18, 2015
- .net has a security system as well, that would prevent changing any fields with reflection except for fully-trusted applications. It's unfortunate that 99% of usage is in fully-trusted applications though.Feb 18, 2015
- were far from a reasoning machine yet...Feb 18, 2015
- I guess the first few integers are cached as constants,but I wouldn't always count on 6 == 6, that is kind of implementation dependant. The 2nd one makes sense. No idea what the type math does, but padding numbers with 0 is always a bad ideaFeb 18, 2015
#1 and #2 are one of those cases where the optimization to get a little speed ends up being one of those Gotcha's that can make developers turn old before their time.
If you don't know about that little detail, that integers -127 to 128 are cached, or different ranges depending on implementation, you could end up with a bug that'll be pretty hard to track down.
IMHO, always use Equals when comparing objects, unless you want to test if two objects are references to the same instance, or not.
#3 I doubt any sane developer would try, but you essentially have two - signs, making it a plus.
#4 is perfectly valid. is it a Gotcha? It probably can be to some, if they are unaware of the 0XX notation used for Octal (base-8) numbers. It did get me once, after a number of regexp operations on a dataset, I had a lengthy array of numbers, and didn't spot that some of them had a leading 0.
But having octals can be convenient.Feb 19, 2015
- I think I need to see a head doctor because all of this makes sense to meFeb 19, 2015
Add a comment...