Skip to content
Snippets Groups Projects
SetUtil.java 248 B
Newer Older
  • Learn to ignore specific revisions
  • TRAVERS Corentin's avatar
    TRAVERS Corentin committed
    package util;
    
    import java.util.NoSuchElementException;
    import java.util.Set;
    
    public class SetUtil {
        public static <T> T anyElement(Set<T> elements){
            return elements.stream().findAny().orElseThrow(NoSuchElementException::new);
        }
    }