This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
1)JVM support for dynamic languages, following the prototyping work currently done on the Multi Language Virtual Machine
2)Compressed 64-bit pointers Available in Java 6 with -XX:+UseCompressedOops
3)Small language changes (grouped under a project named Coin):
3.1)The ability to cast from an Object type to a primitive type directly
3.2)Strings in switch
3.3)Automatic resource management in try-statement
3.4)Improved type inference for generic instance creation
3.5)Simplified varargs method declaration
3.6)Binary integer literals
3.7)Allowing underscores in numeric literals
3.8)Catching multiple exception types and rethrowing exceptions with improved type checking
What is "3.1)The ability to cast from an Object type to a primitive type directly".? It will be very helpful to explain this feature.Thanks in advance.
Aniruddh Joshi wrote:Thanks Rob.
If I get it right now I can cast any object to a primitive.
Only if the object is a primitive wrapper of the right type (Integer + int, Long + long, etc). Otherwise the compiler won't complain but you'll get a ClassCastException. That's because line 12 is actually a cast to Integer, then auto unboxing: