Java Utililty Methods List First Item

List of utility methods to do List First Item

Description

The list of methods to do List First Item are organized into topic(s).

Method

Listfirst_nItems(int n, Collection fromList)
firsn Items
if (n >= fromList.size())
    return new ArrayList<T>(fromList);
return (new ArrayList<T>(fromList)).subList(0, n);
BooleanfirstBoolean(List list)
first Boolean
A a = first(list);
if (a == null) {
    return null;
if (a instanceof Boolean) {
    return (Boolean) a;
try {
...
booleanfirstColumnRemovable(List data)
first Column Removable
boolean allEmpty = true;
for (String s : data) {
    if (s.length() == 0) {
        continue;
    allEmpty = false;
    final char c = s.charAt(0);
    if (c != ' ' && c != '\t') {
...
EfirstElement(List list)
Returns the first element of the given List .
int index = 0;
return elementAt(list, index);
TfirstItem(Iterable list)
Provides the first item of the given list.
if (list != null) {
    Iterator<T> i = list.iterator();
    if (i.hasNext()) {
        return i.next();
return null;
TfirstItem(List items)
first Item
if (items == null) {
    return null;
Iterator<T> iterator = items.iterator();
if (iterator.hasNext()) {
    return iterator.next();
return null;
...
StringfirstMatch(List src, String... lookup)
first Match
if (lookup == null) {
    return null;
Arrays.sort(lookup);
for (String s : src) {
    int matchedIndex = Arrays.binarySearch(lookup, s);
    if (matchedIndex >= 0) {
        return lookup[matchedIndex];
...
ObjectfirstObjectFromList(List list)
first Object From List
Object result = null;
if (list != null && list.size() > 0) {
    result = list.get(0);
return result;
TfirstOrDefault(List items)
first Or Default
if (items.size() < 1)
    return null;
return items.get(0);
StringfirstStartsWith(List lines, String startsWith)
return first line that starts with prefix, null otherwise
for (String l : lines) {
    if (l.startsWith(startsWith)) {
        return l;
return null;