Generic method to select Value from array - Android java.lang

Android examples for java.lang:array

Description

Generic method to select Value from array

Demo Code

import android.widget.AdapterView;

public class Main{

    public static <T> T selectedValue(T[] values, long index) {
        T result = null;// w  w  w. j a  va2s  .c  o  m
        if (index != AdapterView.INVALID_ROW_ID) {
            result = values[(int) index];
        }
        return result;
    }
    public static Integer selectedValue(int[] values, long index) {
        Integer result = null;
        if (index != AdapterView.INVALID_ROW_ID) {
            result = values[(int) index];
        }
        return result;
    }

}

Related Tutorials