public void printAllAutomobile() { ListIterator<Automobile> it1 = vehlist.listIterator(); while (it1.hasNext()) { Automobile t = it1.next(); System.out.println( "type:" + t.getClass().getName() + ",engine:" + t.getEngineCc() + ", age:" + t.getAge()); } }
public List<Automobile> getAutoOfEngineAndAge(int cc, int age) { List<Automobile> selList = new ArrayList<Automobile>(); for (Automobile a : vehlist) { if (a.getEngineCc() == cc && a.getAge() > age) { selList.add(a); } else { } } return selList; }