public class PezDispenser { public static void main(String[] args) { Stack dispenser = new Stack(); Candy[] candies = new Candy[15]; candies = buyCandy(); for (Candy piece : candies) { dispenser.push(piece); } System.out.println("You've filled your PEZ dispenser!"); for (Candy piece : candies) { dispenser.pop(); } //This is the same as: /* for (int i = 0; i < candies.length; i++) { dispenser.pop(); } */ System.out.println("You've now eaten all your candies! Don't you feel sick?"); } private static Candy[] buyCandy() { Candy[] candies = new Candy[15]; /* Snippet of code that "buys" 15 pieces of candy (setting the array) */ return candies; } }