private static List customers; { customers = new ArrayList(); customers.add(new Customer(101, "John")); customers.add(new Customer(201, "Russ")); customers.add(new Customer(301, "Kate")); } public Customer get(Long id) { for (Customer c :customers) /*here "customers" and "c" both having different data type . Is it possible in this loop? */ { if (c.getId().equals(id)) { return c; } } return null; } /*here "customers" and "c" both having different data type . Is it possible in this loop *? If no. Then how to read List objects having different-different data type using enhance for loop? | 0 |