Example usage for java.util List get

List of usage examples for java.util List get

Introduction

In this page you can find the example usage for java.util List get.

Prototype

E get(int index);

Source Link

Document

Returns the element at the specified position in this list.

Usage

From source file:Main.java

public static void main(String args[]) {
    Vector<String> v1 = new Vector<String>();
    v1.add("A");/*from w w w . j av a 2s.  c o  m*/
    v1.add("B");
    v1.add("C");
    List l = v1.subList(1, 2);

    for (int i = 0; i < l.size(); i++) {
        System.out.println(l.get(i));
    }
}

From source file:MainClass.java

public static void main(String args[]) {
    Vector v1 = new Vector();
    v1.add("A");/* www  .  j a v  a2  s  .  c om*/
    v1.add("B");
    v1.add("C");
    List l = v1.subList(1, 2);

    for (int i = 0; i < l.size(); i++) {
        System.out.println(l.get(i));
    }
}

From source file:Main.java

public static void main(String[] args) {
    Integer[] numbers = { 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 };

    List list = Arrays.asList(numbers);

    for (int i = 0; i < list.size(); i++) {
        System.out.print(list.get(i) + ", ");
    }//from  www . j a  va2s .  c  om
}

From source file:edu.scripps.fl.pubchem.app.RelatedCurveProcessor.java

public static void main(String[] args) throws Exception {
    CommandLineHandler clh = new CommandLineHandler();
    args = clh.handle(args);/*from w w w . j  a va 2s .com*/

    Integer[] list = (Integer[]) ConvertUtils.convert(args, Integer[].class);
    Integer referenceAid = list[0];
    Integer[] relatedAids = new Integer[list.length - 1];
    System.arraycopy(list, 1, relatedAids, 0, list.length - 1);

    URL url = PipelineUtils.class.getClassLoader()
            .getResource("edu/scripps/fl/pubchem/RelatedCurvesPipeline.xml");
    Pipeline pipeline = new PipelineUtils().createPipeline(url, Arrays.asList(relatedAids));
    List<Stage> stages = pipeline.getStages();
    BeanUtils.setProperty(stages.get(1), "referenceAID", referenceAid);
    pipeline.run();
    new PipelineUtils().logErrors(pipeline);
}

From source file:Main.java

public static void main(String[] args) {
    Set<Object> set = new HashSet<Object>();
    set.add("A");
    set.add(new Long(10));
    set.add(new Date());

    List<Object> list = new ArrayList<Object>(set);
    for (int i = 0; i < list.size(); i++) {
        Object o = list.get(i);
        System.out.println("Object = " + o);
    }//from   w  ww. j a  v  a  2s . co  m
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {

    List list = new ArrayList();
    list.add("A");
    list.add("B");
    list.add("C");

    System.out.println(list.get(2));

}

From source file:Main.java

public static void main(String[] args) {
    ArrayList<String> arrayList = new ArrayList<String>();

    arrayList.add("1");
    arrayList.add("2");
    arrayList.add("3");
    arrayList.add("4");
    arrayList.add("5");

    List lst = arrayList.subList(1, 3);
    for (int i = 0; i < lst.size(); i++)
        System.out.println(lst.get(i));

    // remove one element from sub list
    Object obj = lst.remove(0);//from ww w. java  2  s.c  o m
    System.out.println(obj + " is removed");

    for (String str : arrayList)
        System.out.println(str);
}

From source file:Main.java

public static void main(String args[]) {
    List<Character> list = new ArrayList<Character>();

    list.add('X');

    System.out.println("Element added to list: " + list.get(0));

    Collection<Character> immutableCol = Collections.unmodifiableCollection(list);

    immutableCol.add('Y');
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    URL url = new URL("http://www.google.com/index.html");
    URLConnection connection = url.openConnection();

    Map responseMap = connection.getHeaderFields();
    for (Iterator iterator = responseMap.keySet().iterator(); iterator.hasNext();) {
        String key = (String) iterator.next();
        System.out.println(key + " = ");

        List values = (List) responseMap.get(key);
        for (int i = 0; i < values.size(); i++) {
            Object o = values.get(i);
            System.out.println(o + ", ");
        }/*from  www .j  a va2s.c o m*/
    }
}

From source file:Main.java

public static void main(String args[]) throws Exception {

    List<String> list = new ArrayList<String>();
    list.add("A");
    list.add("B");
    list.add("C");

    System.out.println(list.get(2));

}