Get value from an Array

ReturnMethodSummary
static Objectget(Object array, int index)Returns the value of the indexed component in the specified array object.
static booleangetBoolean(Object array, int index)Returns array element as a boolean.
static bytegetByte(Object array, int index)Returns array element as a byte.
static chargetChar(Object array, int index)Returns array element as a char.
static doublegetDouble(Object array, int index)Returns array element as a double.
static floatgetFloat(Object array, int index)Returns array element as a float.
static intgetInt(Object array, int index)Returns array element as an int.
static longgetLong(Object array, int index)Returns array element as a long.
static shortgetShort(Object array, int index)Returns array element as a short.

import java.lang.reflect.Array;
import java.util.Arrays;

public class Main {
  public static void main(String[] argv) throws Exception {
    int[] array = { 1, 2, 3 };
    // Get the value of the third element.
    Object o = Array.get(array, 2);
    System.out.println("o:"+o);
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.