title: Casting between ArrayLists in Java
body: <p>Sorry, I thought this was an inheritance question: it was an ArrayList question all along!</p>
  
  <p>Ok, my problem is more specific than I thought. So I have two families of classes. Cards, and Zones. Zones are boxes for holding card. </p>
  
  <p>The first two subClasses of Zone, ZoneList and ZoneMap are meant to be two different ways of storing Cards. Further subclasses, such as Hand, and PokerHand, have their own specific ways of dealing with the cards they store. </p>
  
  <p>Where it gets complicated is that Card also has subClasses, such as PokerCard, and that the subclasses of ZoneList and ZoneMap are meant to organize those. </p>
  
  <p>So in ZoneList I have <code>protected ArrayList&lt;Card&gt; cardBox;</code> and in PokerHand I expected to be able to declare <code>cardBox = new ArrayList&lt;PokerCard&gt;();</code> since PokerCard is a Card. The error I am getting is that I apparently can't cast between Card and GangCard when it comes to ArrayLists... So I was trying to fix this by just redeclaring cardBox as <code>private ArrayList&lt;PokerCard&gt; cardBox;</code> inside PokerHand, but that resulted in the hiding that was bugging up my program.</p>
  
  <p>SO really, the question is about casting between ArrayLists? Java tells me I can't, so any ideas on how I can?</p>
  
  <p>z.</p>