Warning: include_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/users/2/moriya-h5/web/confrage/java/list/linkedlist/linkedlist.html on line 2

Warning: include_once(http://www.confrage.com/bin/header.php): failed to open stream: no suitable wrapper could be found in /home/users/2/moriya-h5/web/confrage/java/list/linkedlist/linkedlist.html on line 2

Warning: include_once(): Failed opening 'http://www.confrage.com/bin/header.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/list/linkedlist/linkedlist.html on line 2
LinkedList | Java | 株式会社CONFRAGE
Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/list/linkedlist/linkedlist.html on line 17

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/list/linkedlist/linkedlist.html on line 17
LinkedList
LinkedListはListインターフェースを実装したクラスで、動的配列のようなものです。
要素は重複要素を許し、インスタンス作成時の配列サイズ(new LinkedList().size())は0です。
要素を追加(add)するたびにサイズは+1されます。逆に削除(remove)するとサイズは-1されます。
配列サイズ外の要素にアクセスするとIndexOutOfBoundsExceptionがスローされます。

以下、サンプルです。

import java.util.LinkedList;
import java.util.List;

public class Test {
    public static void main(String[] args) {
        List list = new LinkedList();
        System.out.println("インスタンス作成時のサイズ = " + list.size());
        list.add(0,"ccc");
        System.out.println(list.size());
        list.add(0,"bbb");
        System.out.println(list.size());
        list.add(2,"aaa");
        System.out.println(list.size());
        
        for(int i=0;i<list.size();i++){
            System.out.println("list要素" + i + " = " + list.get(i));
        }
    }
}
実行結果は以下のようになります。

インスタンス作成時のサイズ = 0
1
2
3
list要素0 = bbb
list要素1 = ccc
list要素2 = aaa

Back to top

Information

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/list/linkedlist/linkedlist.html on line 90

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/list/linkedlist/linkedlist.html on line 90

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/seo.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/list/linkedlist/linkedlist.html on line 99

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/seo.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/list/linkedlist/linkedlist.html on line 99