Lecture 12
3
Casting
•Syntax: (Bar)foo tells the compiler to treat object foo as something of type Bar
•ArrayList get returns an anonymous Object
•   for (int i = 0; i<myList.size(); i++ ){      SimpleObject foo =                (SimpleObject)myList.get(i);   System.out.println                    (i + "\t" + foo.name);
•  }
•Perhaps the compiler ought to know, but it doesn’t