有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

Java Casting ArrayIterator<Object>

queryMe方法返回一个ArrayIterator<;我>;。queryYou方法返回一个ArrayIterator<;你>

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.

有什么建议吗


共 (1) 个答案

  1. # 1 楼答案

    你不能强制转换它,因为ArrayIterator<Me>不是ArrayIterator<Java.lang.object>的子类型。事实上,这两种类型是不相关的

    Find more explanation