Remember, you can Box then Widen, but you can't Widen then Box. Beforehand, if you did float f = 5, the integer would be implicitly widened into a float, but since you can't implicitly widen the int to a float before boxing it as a Float, this doesn't work. [ February 08, 2006: Message edited by: Craig Tyler ]
Originally posted by Craig Tyler: Remember, you can Box then Widen, but you can't Widen then Box. Beforehand, if you did float f = 5, the integer would be implicitly widened into a float, but since you can't implicitly widen the int to a float before boxing it as a Float, this doesn't work.
can i make a guess? maybe 97 is the ascii decimal equivalent of the letter 'a' .
That's the easy part. The hard past is why it allowed "Integer i = 'a'". Maybe the specs for autoboxing have changed a little or maybe Eclipse has got it wrong...
have you tried it on eclipse IDE, with java 5 and 'a' as char (i mistakenly tried it as string at first)? i think im getting interested with this, thanks for bringing up the topic
Does Eclipse use different compiler other than Sun's JDK 1.5?
As far as I know Eclipse provides different graphics package (SWT) which is different than Swing.
If Integer i = 'a'; works in one implementation as you are reporting in the case of Eclipse and does not work on Sun's implementation then one of them must have a bug.
Alqtn
They worship nothing. They say it's because nothing lasts forever. Like this tiny ad:
a bit of art, as a gift, that will fit in a stocking