why does the following line of code give me a compile error?:
shouldn't this guarantee that the objecty passed to the variable will be cast down into a "Long"?Code:Long l = (Class.forName("java.lang.Long")) ((Object) ( new Long (123)));
Printable View
why does the following line of code give me a compile error?:
shouldn't this guarantee that the objecty passed to the variable will be cast down into a "Long"?Code:Long l = (Class.forName("java.lang.Long")) ((Object) ( new Long (123)));
Class.forName() returns an instance of the class you pass in. Its a method, not an operator. For casting, you just do it the way you casted the Long to an Object.
:)Code:Long l = (Long)((Object) (new Long (123)));