Java array, NullPointerException?

前端 未结 2 383
旧时难觅i
旧时难觅i 2020-11-29 13:54

I declared two cards:

Card card1 = new Card(\'3\', Card.Suit.clubs);
Card card2 = new Card(\'T\', Card.Suit.diamonds);

This works:

相关标签:
2条回答
  • 2020-11-29 14:36

    I think you need to go though this... I will clear your concepts... Please refer Java tutorials as and when possible.. its helpful

    http://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html

    0 讨论(0)
  • 2020-11-29 14:41

    You are declaring an array of 2 hands. This is just setting up the array. You then need to instantiate the hand objects inside the array.

    Say

    hand[0] = new Hand(); 
    hand[1] = new Hand();
    
    0 讨论(0)
提交回复
热议问题