Do Java collections have a built-in method for returning multiple items from this collection? For example, the list below contains n items, some of which are duplicated in the list. How can I get all the elements where value = "one"? I understand that it would be very easy to write my own method to achieve this functionality, I just wanted to make sure that I lacked the built-in method for this.
List<String> ls=new ArrayList<String>(); ls.add("one"); ls.add("two"); ls.add("three"); ls.add("one"); ls.add("one");
thanks
source share