0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ArrayList, LinkedList, Vector

Posted at

ArrayListは動的配列拡張
LinkedListは数珠繋ぎ
Vectorはthread safe

public class Outer {
    public static void main(String args[]) {
        List<String> l = new ArrayList<>();
        l.add("A");
        l.add("B");
        l.add("C");
        l.forEach(System.out::println);
        Consumer con = x -> System.out.println("--------");
        con.accept(null);
        l.parallelStream().forEach(System.out::println);
        con.accept(null);
        List<String> l2 = new LinkedList<>();
        l2.add("A");
        l2.add("B");
        l2.add("C");
        l2.forEach(System.out::println);
        con.accept(null);
        l2.parallelStream().forEach(System.out::println);
        Vector<String> v = new Vector<>();
        con.accept(null);
        v.add("A");
        v.add("B");
        v.add("C");
        v.forEach(System.out::println);
        con.accept(null);
        v.parallelStream().forEach(System.out::println);   //thread safe
    }
}
A
B
C
--------
B
C
A
--------
A
B
C
--------
B
C
A
--------
A
B
C
--------
B
C
A
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?