为什么此代码不起作用?具体来说,为什么在if语句之外完成的类型转换不在其中。关于if语句在Java中进行类型转换
private SuperType currObj;
public void someMethod(SuperType currObj){
if(currObj instanceof aSubType){
currObj = (aSubType) currObj;
if (true){
currObj.someMethodofaSubtype();
}
}
}
你还必须有变量名可以是混乱的一些混合。你可以帮助指定哪个是通过'this'关键字。 – jbrookover 2011-04-03 01:38:26