import java.util.*; public class Alice3 { public Alice3() { // Fill the ArrayList. ArrayList battle = new ArrayList(); // Not the syntax for generic object storing. for (int i = 0; i < 100; i++) { if (Math.random() < 0.5) { battle.add("Tweedledum"); } else { battle.add("Tweedledee"); } } // Delete one String type. Object[] battleArray = battle.toArray(); // Note the different method from Alice.java for (Object person: battleArray) { if (((String)person).equals("Tweedledum")) { // Note we now need a cast, as we're dealing with generic objects. battle.remove(person); } } // Test. battleArray = battle.toArray(); // Refresh the array with the new contents. for (Object person: battleArray) { System.out.println((String)person); // Note we now need a cast, as we're dealing with generic objects. } } public static void main (String args[]) { new Alice3(); } }