ArrayList<classA> aList = /*I then fill this array*/
ArrayList<classB> bList = /* I then fill this array too*/
/*Now put them both in the following ArrayList of Objects*/
ArrayList<Object> myObjs = new ArrayList<Object>();
myObjs.add(aList);
myObjs.add(bList);
/*The following two lines however fails at run time*/
ArrayList<classA> x = (ArrayList<classA>) myObjs.get(0);
ArrayList<classB> x = (ArrayList<classB>) myObjs.get(1);
我刚刚从另一个线程中读到“当有可能在运行时成功时允许向下转换”
谁能告诉我上面代码的问题?非常感谢!