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/set/treeset/treeset.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/set/treeset/treeset.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/set/treeset/treeset.html on line 2
TreeSet | 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/set/treeset/treeset.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/set/treeset/treeset.html on line 17
TreeSet
TreeSetはSetインターフェースを実装したクラスで、挿入した値を、値の昇順に保持します。また、重複する要素を追加しても重複して保持はされません。
イテレートすると、値の昇順で値が返ります。

以下、サンプルです。

import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

public class ExIterator {
    public static void main(String[] args) {

        Set set = new TreeSet();
        set.add("2");
        set.add("1");
        set.add("1");
        set.add("3");
        set.add("1");
        set.add("4");
        
        Iterator itr = set.iterator(); 
        while (itr.hasNext()) {
            String element = (String)itr.next();
            System.out.println(element);
        }  
    }
}
実行結果は以下のようになります。

1
2
3
4

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/set/treeset/treeset.html on line 88

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/set/treeset/treeset.html on line 88

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/set/treeset/treeset.html on line 97

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/set/treeset/treeset.html on line 97