T
Tony Johansson
Hello!
Can somebody tell me why this
Object o = 1;
long d = (long)o;
doesn't work.
Here I know that the value 1 is copied and created on the heap and
the reference o which exist on the stack is refering to the created memory
on the heap.
I know that this will throw invalidcastException and the cast must have
exactly the same type
in this case int.
But I mean that assigning an int to a long would'n be too bad so
the run time could exept it.
I mean this works fine assigning an int to long
int i = 1;
long l = i;
//Tony
Can somebody tell me why this
Object o = 1;
long d = (long)o;
doesn't work.
Here I know that the value 1 is copied and created on the heap and
the reference o which exist on the stack is refering to the created memory
on the heap.
I know that this will throw invalidcastException and the cast must have
exactly the same type
in this case int.
But I mean that assigning an int to a long would'n be too bad so
the run time could exept it.
I mean this works fine assigning an int to long
int i = 1;
long l = i;
//Tony