On 21/12/2007, at 1:48 AM, Tore Halset wrote:
> I have been bitten by a couple of situations where I thought my
> primitive type was primitive, but in fact had been autoboxed. This
> is extra confusing when you have objects that have identical
> methods, but with primitive and non primitive arguments. Like
> List<Integer>.remove(int) and List<Integer>.remove(Integer) doing
> two very different things. It is also a bit confusing when
> autoboxing happens when you do not know about it. I do not have that
> many good examples, but have googled some discussion around the
> subject.
>
> http://episteme.arstechnica.com/eve/forums/a/tpc/f/6330927813/m/867001348831/r/448008648831
> http://www.theserverside.com/news/thread.tss?
I agree that it can be confusing in some cases, but it isn't like we
can just switch it off. The places where it is confusing is where it
happens without you realising it is happening. The places where it
makes the code easier to read (IMO) are when you use it intentionally
and might look like this:
static public Integer SOME_CONSTANT = 5;
But really, I think it a pretty minor issue. I wasn't aware of the
speed enhancement of Integer.valueOf(int) and that is pretty nice as
long as we are sure those particular Integers are immutable.
Ari
-------------------------->
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001 fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A
This archive was generated by hypermail 2.0.0 : Thu Dec 20 2007 - 16:49:55 EST