queryMe方法返回一個ArrayIterator < Me>。 queryYou方法返回一個ArrayIterator < You>。Java Casting ArrayIterator <Object>
public ArrayIterator<Object> query(String table, String field, String criterion)
{
ArrayIterator<Object> result = null;
if (table.equals("MyTable")
{
result = MyTable.queryMe(field, criterion);
}
else if (table.equals("YourTable")
{
result = YourTable.queryYou(field, criterion);
}
return result;
}
我收到說
ArrayIterator<Me> and ArrayIterator<Java.lang.object> are incompatible types.
任何建議的錯誤?
由於錯誤說,我覺得你應該創建和類型,而不是與類型的對象 –
cakil
返回ArrayIterator返回ArrayIterator這種方法比複雜得多,它具有許多其他if語句。爲了簡單起見,我只發佈了一個。我即將編輯它。 –
認爲ArrayIterator是ArrayIterator