Lists HashMap Sets Iterators Java

Return element from a set having single element

Case where you know you will have only single element in list after your processing and wish to return the element and you dont know what is the actual class

Element ele= set.iterator().next();


return set.iterator().next();
Edit this page on GitHub

Links to this note