Präsentation herunterladen
Die Präsentation wird geladen. Bitte warten
1
Arrays of Objects, a 3 part process
Die [] yahtzee; yahtzee null
2
Die [] yahtzee; yahtzee = new Die[5]; null yahtzee null null null null
3
Die [] yahtzee; yahtzee = new Die[5]; yahtzee[1] = new Die(); null yahtzee null null Yahtzee[4] = new Die();
4
Arrays of Objects, a 3 part process
Die [] yahtzee; yahtzee = new Die[5]; yahtzee[1] = new Die(); null yahtzee null null yahtzee[4] = new Die(); 1. declare the array 2. instantiate the array for (int ii = 0; ii < yahtzee.length; ii++) { if (yahtzee[ii] != null) // guard against null pointer exception yahtzee[ii].roll(); } 3. instantiate each object
Ähnliche Präsentationen
© 2024 SlidePlayer.org Inc.
All rights reserved.