JAVA開発メモ
Collections
 

[リロード]   [新規|編集|差分|添付]   [トップ|一覧|単語検索|最終更新|バックアップ|ヘルプ]

サイトメニュー

import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; public class CollectionsSample { public static void main(String[] args) { List list = new ArrayList(); Collection collection = list; list.add(new Integer(5)); list.add(new Integer(2)); list.add(new Integer(6)); list.add(new Integer(1)); list.add(new Integer(4)); list.add(new Integer(3)); Collections.sort(list); System.out.println(list); int index = Collections.binarySearch(list, new Integer(2)); index = Collections.binarySearch(list, new Integer(4)); index = Collections.binarySearch(list, new Integer(5)); Collections.shuffle(list); System.out.println(list); Collections.sort(list); Collections.reverse(list); System.out.println(list); Collections.rotate(list, 3); System.out.println(list); Collections.sort(list); Collections.swap(list, 0, 5); Collections.swap(list, 1, 4); System.out.println(list); } } [1, 2, 3, 4, 5, 6] [6, 2, 3, 5, 1, 4] [6, 5, 4, 3, 2, 1] [3, 2, 1, 6, 5, 4] [6, 5, 3, 4, 2, 1]

リロード   新規 編集 差分   トップ 一覧 検索 最終更新 バックアップ   ヘルプ   最終更新のRSS
Last-modified: Tue, 15 Feb 2005 14:07:52 UTC (6300d)
Link: (4985d)

Modified by MT22(Moriwaki Takashi)

"PukiWiki" 1.3.7 Copyright © 2001,2002,2003 PukiWiki Developers Team. License is GNU/GPL.
Based on "PukiWiki" 1.3 by sng
Powered by PHP 7.4.28

HTML convert time to 0.021 sec.