Java 程式設計 -- 容器
Java 程式簡介運算式分枝迴圈陣列函數遞迴錯誤處理物件導向封裝繼承多型技巧函式庫字串數學正規表達式容器檔案網路資料庫視窗ThreadListener錯誤陷阱相關檔案相關資源教學錄影Eclipse考題解答訊息相關網站參考文獻最新修改簡體版English |
範例:Vector 的使用import java.util.Vector; class Vector1 { public static void main(String[] args) throws Exception { String[] names={"大毛","二毛","小毛"}; String[] tels={"082-31333","082-31111","082-31222"}; Vector v = new Vector(); for (int i=0; i<names.length; i++) v.add(names[i]+" "+tels[i]); System.out.println("v="+v); } } 範例:TreeMap 的使用import java.util.TreeMap; class Map1 { public static void main(String[] args) throws Exception { String[] names={"大毛","二毛","小毛"}; String[] tels={"082-31333","082-31111","082-31222"}; TreeMap map = new TreeMap(); for (int i=0; i<names.length; i++) map.put(tels[i], names[i]); System.out.println(map); } } |
page revision: 1, last edited: 04 Nov 2010 05:24
Post preview:
Close preview