singleLines.java 554 B

123456789101112131415161718192021
  1. LinkedList<MyType> myList = new LinkedList<MyType>();
  2. List<MyType> myList = new LinkedList<MyType>();
  3. import java.util.List;
  4. Animal a = new Animal();
  5. // The compiler can resolve this method call statically:
  6. a.Roar();
  7. public void MakeSomeNoise(object a) {
  8. // Things happen...
  9. // You won't know if this works until runtime:
  10. ((Animal) a).Roar();
  11. }
  12. for (Map.Entry<Person, TelephoneNumber>
  13. entry : phonebook.entrySet()) {
  14. Person k = entry.getKey();
  15. TelephoneNumber v = entry.getValue();
  16. System.out.println(k + " " + v);
  17. }