void (String[] args) { MyList list = new MyList(); List<Integer> integerList = new ArrayList<>(); for (Object element : li<caret>st) { if (element instanceof Integer) { integerList.add((Integer) element); } } }