Java Collection Element Get getArbitraryMember(Collection s)

Here you can find the source of getArbitraryMember(Collection s)

Description

get Arbitrary Member

License

Open Source License

Declaration

static public <T> T getArbitraryMember(Collection<T> s) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * SiniaUtils// w ww . j  ava2s  .c o m
 * Copyright (c) 2011-2 Siniatech Ltd  
 * http://www.siniatech.com/products/siniautils
 *
 * All rights reserved. This project and the accompanying materials are made 
 * available under the terms of the MIT License which can be found in the root  
 * of the project, and at http://www.opensource.org/licenses/mit-license.php
 *
 ******************************************************************************/

import java.util.Collection;

public class Main {
    static public <T> T getArbitraryMember(Collection<T> s) {
        return s.isEmpty() ? null : s.iterator().next();
    }
}

Related

  1. getAllTopicsAsString(final Collection topics)
  2. getAncestors(Collection> classes)
  3. getAnElement(Collection coll)
  4. getAny(final Collection collection)
  5. getAnyFrom(Collection collection)
  6. getArray(Collection dnaCol)
  7. getArrayFromCollection( Collection collection)
  8. GetArrayFromCollection(java.util.Collection col)
  9. getArrays(Object parent, Collection collection)