001 package collections; 002 003 import java.util.ArrayList; 004 005 public class RawType { 006 public void forEachLoop(ArrayList list) { // raw type 007 for (Object o : list) { 008 Gerbil g = (Gerbil) o; // down cast 009 g.jump(); 010 } 011 } 012 013 public static void main(String[] args) { 014 ArrayList<Gerbil> gerbils = new ArrayList<Gerbil>(); 015 for (int i = 0; i < 42; i++) { 016 gerbils.add(new Gerbil(i)); // up cast 017 } 018 RawType raw = new RawType(); 019 raw.forEachLoop(gerbils); 020 } 021 }