I was wondering if you can cast an object[] to another object[] of a different class.
Here's what I tried doing, but clearly it isn't working.
public CardCollection() {
CardCollection[] myCollection = new CardCollection[MAX_CARDS];
for(int i = 0; i < myCollection.length; i++){
myCollection[i] = (BaseballCard[]) Collection[i];
}
}
I'm getting an error when I tried casting the collection Object[] to BaseballCard.
I had previously made a
BaseBallCard[] Collection = new BaseBallCard[MAX_CARDS]; // MAX_CARDS=100;
I have tried myCollection[i]= (BaseballCard) Collection[i]. Gave me an error saying BaseballCard cannot be resolved to a type.