Example usage for java.util List size

List of usage examples for java.util List size

Introduction

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

Prototype

int size();

Source Link

Document

Returns the number of elements 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  . ja  v a  2 s  . 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");/*w  w w .  jav a  2  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) + ", ");
    }/*  w  w  w  .java 2  s.  c  o m*/
}

From source file:RegisteredNameDemo.java

public static void main(String[] args) {
    ScriptEngineManager manager = new ScriptEngineManager();
    List<ScriptEngineFactory> factories = manager.getEngineFactories();
    for (ScriptEngineFactory factory : factories) {
        List<String> regNames = factory.getNames();
        for (int i = 0; i < regNames.size(); i++) {
            System.out.printf("Registered name " + i + " " + (String) regNames.get(i) + "\n");
        }// ww w . j  a  v a2  s . c o  m
    }
}

From source file:FileExtensionsDemo.java

public static void main(String[] args) {
    ScriptEngineManager manager = new ScriptEngineManager();
    List<ScriptEngineFactory> factories = manager.getEngineFactories();
    for (ScriptEngineFactory factory : factories) {
        List<String> ext = factory.getExtensions();
        for (int i = 0; i < ext.size(); i++) {
            System.out.printf("Supported file extension: " + (String) ext.get(i) + "\n");
        }/*from w ww .j  av a 2  s.  c  o m*/
    }
}

From source file:Main.java

public static void main(String[] a) {
    List list = Arrays.asList(new String[] { "A", "B", "C", "D" });
    System.out.println(list.size());
    System.out.println(list.isEmpty());
}

From source file:Main.java

public static void main(String[] a) {
    List list = Arrays.asList(new String[] { "A", "B", "C", "D" });
    System.out.println(list.size());
    System.out.println(list.hashCode());
}

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);/* w  w w . jav a2  s.c  o m*/
        System.out.println("Object = " + o);
    }
}

From source file:MimeTypesDemo.java

public static void main(String[] args) {
    ScriptEngineManager manager = new ScriptEngineManager();
    List<ScriptEngineFactory> factories = manager.getEngineFactories();
    for (ScriptEngineFactory factory : factories) {
        List<String> mimeTypes = factory.getMimeTypes();
        for (int i = 0; i < mimeTypes.size(); i++) {
            System.out.printf("Supported MIME type " + i + " " + (String) mimeTypes.get(i) + "\n");
        }//from w w w  .j a  va 2 s .  c  o  m
    }
}

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);/*w ww . j  av  a  2 s  . com*/
    System.out.println(obj + " is removed");

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