Hi Dirk,
Check the following codes:
___________________________________________
code 1)
public class Foo{
public static void main(String[] args) {
Object[] objects = new Object[2];
objects[0] = "one";
objects[1] = "two";
String[] strings = (String[])objects;
}
}
___________________________________________
code 2)
public class Foo{
public static void main(String[] args) {
Object object = new Object();
object = "one";
String string = (String)object;
}
}
___________________________________________
The code 1) has a ClassCastException at runtime.But the code 2) results in no exception at runtime.In this case,The casting conversion does not work with Object array only.Do I understand correctly?
But array is also a kind of Object,why the casting conversion works on all kinds of object,only except for array?
I know a little about 'Pass by value/reference',Polymorphism.Otherwise it's a shame since I just passed SCJP several months ago.
But frankly,the campfire stories is very funny and helpful,and the 'remote controller'(object reference) impress me strongly.Thanks a lot for your recommendation reading.
xusoo