Example usage for java.util List remove

List of usage examples for java.util List remove

Introduction

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

Prototype

E remove(int index);

Source Link

Document

Removes the element at the specified position in this list (optional operation).

Usage

From source file:Main.java

public static void main(String args[]) {
    Vector<String> v1 = new Vector<String>();
    v1.add("A");//from  ww w. ja v  a2 s  . c om
    v1.add("B");
    v1.add("C");
    List l = v1.subList(1, 2);

    l.remove(0);

    System.out.println(l);
    System.out.println(v1);
}

From source file:Main.java

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

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

    System.out.println(lList);//from www. j  av a2 s  .  c o  m
    List lst = lList.subList(1, 4);
    System.out.println(lst);

    lst.remove(2);
    System.out.println(lst);
    System.out.println(lList);
}

From source file:Main.java

public static void main(String[] args) {
    List<Integer> first = Arrays.asList(2, 3, 4, 5);
    List<Integer> second = Arrays.asList(1, 3, 4, 6);

    List<Integer> missing = new LinkedList<Integer>();
    List<Integer> added = new LinkedList<Integer>(second);

    for (Integer i : first) {
        if (!added.remove(i)) {
            missing.add(i);/*www  .  j  av a2  s . co m*/
        }
    }

    System.out.println("Missing ints in second: " + missing);
    System.out.println("New ints in second: " + added);
}

From source file:MainClass.java

public static void main(String args[]) {
    String init[] = { "One", "Two", "Three", "One", "Two", "Three" };
    List list1 = new ArrayList(Arrays.asList(init));
    List list2 = new ArrayList(Arrays.asList(init));
    list1.remove("One");
    System.out.println(list1);/*from  w w  w.j a  va2 s.  com*/
    list2.removeAll(Collections.singleton("One"));
    System.out.println(list2);
}

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.remove(0));
    System.out.println(list.remove("B"));
    System.out.println(list);//  w w w .j a  va  2 s .com

}

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.remove(0));
    System.out.println(list.remove("B"));
    System.out.println(list);/*from   w  w w .  ja v a  2 s  .  co m*/

}

From source file:Main.java

public static void main(String args[]) {
    String init[] = { "One", "Two", "Three", "One", "Two", "Three" };

    // create two lists
    List<String> list1 = new ArrayList<String>(Arrays.asList(init));
    List<String> list2 = new ArrayList<String>(Arrays.asList(init));

    // remove from list1
    list1.remove("One");
    System.out.println("List1 value: " + list1);

    // remove from list2 using singleton
    list2.removeAll(Collections.singleton("One"));
    System.out.println("The SingletonList is :" + list2);
}

From source file:gov.nih.nci.cacis.mirth.XSLForMirthFormatter.java

/**
 * @param args - main method args/* www.  j ava 2  s.  c om*/
 * @throws IOException - error thrown, if any
 * @throws URISyntaxException - error thrown, if any
 */
public static void main(String[] args) throws IOException, URISyntaxException {
    if (args.length < 2) {
        LOG.error("Usage: XSLForMirthFormatter <formatted-file-output-dir> <xsl-file-1> <xsl-file-2> ...");
        System.exit(1);
    }
    final List<String> lst = new ArrayList<String>(Arrays.asList(args));
    lst.remove(0);
    final XSLForMirthFormatter frmtr = new XSLForMirthFormatter();
    frmtr.formatXSL(args[0], (String[]) lst.toArray(new String[lst.size()]));
}

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);
    System.out.println(obj + " is removed");

    for (String str : arrayList)
        System.out.println(str);//from w ww  .  j  av a  2  s . c  o m
}

From source file:Main.java

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

    list.add("A");
    list.add("B");
    list.add("C");
    list.add("C");
    list.add("C");
    list.add("C");
    list.add("C");

    for (String s : list) {
        if (s.equals("B")) {
            list.remove("B");
        }//ww w.  ja v a  2s  .c o m
        System.out.println(s);
    }
}