Java List First Item getFirstColumn(List> llo, String reason)

Here you can find the source of getFirstColumn(List> llo, String reason)

Description

Gets the first column.

License

Open Source License

Parameter

Parameter Description
llo the llo
reason the reason

Return

the first column

Declaration

public static List<Object> getFirstColumn(List<List<Object>> llo,
        String reason) 

Method Source Code

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

import java.util.ArrayList;
import java.util.List;

public class Main {
    /**//from   www  .  j av a  2  s  . c o  m
     * Gets the first column.
     *
     * @param llo the llo
     * @param reason the reason
     * @return the first column
     */
    public static List<Object> getFirstColumn(List<List<Object>> llo,
            String reason) {
        return getNthColumn(llo, 0, reason);
    }

    /**
     * Gets the nth column.
     *
     * @param llo the llo
     * @param n the n
     * @param reason the reason
     * @return the nth column
     */
    public static List<Object> getNthColumn(List<List<Object>> llo, int n,
            String reason) {
        List<Object> lo = new ArrayList<Object>();
        for (int i = 0; i < llo.size(); i++) {
            if (llo.get(0).size() < n)
                throw new RuntimeException("Insufficient column results, "
                        + reason);
            lo.add(llo.get(i).get(n));
        }
        return lo;
    }
}

Related

  1. getFirst(List l)
  2. getFirst(List list)
  3. getFirst(List list)
  4. getFirst(List source)
  5. getFirstAsString(Map> multiValueMap, String key)
  6. getFirstDuplicateValue(List values)
  7. getFirstElement(List list)
  8. getFirstElement(List collection)
  9. getFirstElement(List list)