Java Collection Last getLastOfCollection(Collection collection)

Here you can find the source of getLastOfCollection(Collection collection)

Description

get Last Of Collection

License

Open Source License

Declaration

@SuppressWarnings("unchecked")
    public static <T> T getLastOfCollection(Collection<T> collection) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;

public class Main {
    @SuppressWarnings("unchecked")
    public static <T> T getLastOfCollection(Collection<T> collection) {
        T t = (T) collection.toArray()[collection.size() - 1];
        return t;
    }/*from ww w  . j a v  a2s .  c o  m*/
}

Related

  1. getLast(Collection c)
  2. getLastElement(Collection collection, T defaultValue)
  3. getLastElement(final Collection collection)
  4. getLastOrNull(Collection collection)
  5. implodeCollection(Collection items, String prefix, String suffix, String delimiter, String lastItemSuffix)
  6. lastIndexOfObjectIdentity(Collection collection, Object object)