Iterator<Integer> iterator = set.iterator(); while (iterator.hasNext()) { int a = iterator.next(); if (a > 10) iterator.remove(); } return set;