This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
Originally posted by Denise Saulon: This is a sample from the K&B book (p 559), with a little addition:
I get a compiler error (incompatible types) for this line:
for (Integer o : oa)
If I change it to for (Object o : oa), it's working fine. Integer IS-A Object but how come it is not applicable here?
I would imagine that you are getting the compiler error here because if may be possible that you will try to invoke methods using the Integer reference variable (such as o.intValue()) that Object class cannot do. Consider that an array of Objects is returned when you invoke even though you know that it's an array of Integers. The array is only constructed at run time so at compile time the compiler wont know what the actual array type will be. Regards