0

The queryMe method returns an ArrayIterator<Me>. The queryYou method returns an ArrayIterator<You>.

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;
}

I'm getting an error that says

ArrayIterator<Me> and ArrayIterator<Java.lang.object> are incompatible types.

Any suggestions?


Bootstrap Inline Elements

So at the top of my page I have a title and a facebook logo. Here's a working example: fiddle

So everything is in a neat row at the top of the page. However, I want the logo and the text Join us on... to be on the right side, and the heading stays where it is. I've tried adding class="pull-right" to the 2nd and 3rd <li> elements, like this. But you can see how that really screws up the vertical alignment. Other than the alignment that's how I want it to look.

Any ideas on how to fix the alignment?

4

3 回答 3

2

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

查找更多解释

于 2013-04-14T17:33:00.887 回答
0

你不能转换ArrayIterator<Me>ArrayIterator<Object>,你应该改变queryMe函数的返回类型,但如果你的迭代器总是有类型Me,最好ArrayIterator<Me>在整个程序中使用

于 2013-04-14T17:35:06.067 回答
0

这是你所追求的黑客。首先将其转换为原始 ArrayIterator,然后再转换为 ArrayIterator<Me>。

ArrayIterator<Me> meIter = (ArrayIterator) 结果。

更好的方法是更改​​您的方法以返回 ArrayIterator<Me> 并将结果更改为相同。

***刚刚看到你的更新。该方法似乎试图返回不同类型的 ArrayIterators,因此返回类型为 <Object>。

// Would be nice if the 2 types shared a common super type.   
public ArrayIterator<Object> query(String table, String field, String criterion)
{
    // WARNING, this is a raw generic type, and provides no type safety
    ArrayIterator result = null;

    if (table.equals("MyTable")
    {
        result = MyTable.queryMe(field, criterion);
    }
    else if (table.equals("YourTable")
    {
        result = YourTable.queryYou(field, criterion);
    }
    return (ArrayIterator<Object>) result.
}
于 2013-04-14T17:41:32.070 回答