use the instanceof operator:
if(dealersHand.get(i) instanceof Card)
{
// guaranteed to be safe to cast to Card
}
Type: Posts; User: helloworld922
use the instanceof operator:
if(dealersHand.get(i) instanceof Card)
{
// guaranteed to be safe to cast to Card
}
You're running into that problem because you're not specializing your ArrayList. Casting it to a Card will work, but it's not a good solution since it's possible that dealersHand could contain...
What exception are you getting (please post the message you're gettting)? Your description looks like it should work, though I can see one potential problem when it comes to generic typing.