public void filter(String content) { list2 = new ArrayList<>(); Notification pom= null; for (Notification notification : list1) { if(content.equals(notification.getContent())) { pom = notification; list2.add(pom); } }