0

I'm trying to write a method that get a B that extends SearchBoard(interface), and an M that extends BoardMove(interface).

Now I have written CrossWord(interface), and MyCrossWord that implements CrossWord, but my method is not willing to recognize MyCrossWord as a legit SearchBoard obj.. I know I did something wrong with the generics someplace.

4

1 回答 1

0
<B extends SearchBoard, M extends BoardMove> void someMethod(B board, M move) {
...
}

只要 B 是 SearchBoard、CrossWord 或 MyCrossWord,它就应该接受 MyCrossWord 作为第一个参数。

于 2013-06-16T15:45:33.433 回答