Java Array Element Get getLast(T[] l)

Here you can find the source of getLast(T[] l)

Description

get Last

License

Open Source License

Declaration

public static <T> T getLast(T[] l) 

Method Source Code


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

import java.util.*;

public class Main {
    public static <T> T getLast(List<T> l) {
        return get(l, -1);
    }//from  ww w  . j  a  va  2s.c  o  m

    public static <T> T getLast(T[] l) {
        return get(l, -1);
    }

    public static <T> T get(List<T> l, int i) {
        return get(l, i, null);
    }

    public static <T> T get(List<T> l, int i, T defValue) {
        if (i < 0)
            i += l.size();
        if (i < 0 || i >= l.size())
            return defValue;
        return l.get(i);
    }

    public static <T> T get(T[] l, int i) {
        return get(l, i, null);
    }

    public static <T> T get(T[] l, int i, T defValue) {
        if (i < 0)
            i += l.length;
        if (i < 0 || i >= l.length)
            return defValue;
        return l[i];
    }

    public static double get(double[] l, int i, double defValue) {
        if (i < 0)
            i += l.length;
        if (i < 0 || i >= l.length)
            return defValue;
        return l[i];
    }
}

Related

  1. getArraySubset(T[] array, int start, int end)
  2. getFrequentElement(int[] bcp)
  3. getFrequentElement(int[] bcp)
  4. getItems(T[] items, int[] indices)
  5. getlast(final T[] array)
  6. tail(int[] original)
  7. tail(Object[] array)