I have a generic class Position<E>
and a concrete class Card
. How do I create an array of type Position<Card>
?
I tried: Position<Card>[] suitPositions = (Position<Card>[]) new Object[5];
but I get a ClassCastException.
But when I try: Position<String>[] suitPositions = (Position<String>[]) new Object[5];
it works just fine.
使用原始类型创建数组:
Position<String>[] suitPositions = new Position[5];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.