跳到主要內容

Collection與Map筆記


Collection -> Iterator -hasNext() -next() -remove()
  • Set 不重複,取值要用foreach
    • HashSet 最基本的set,與輸入順序不同(why?)
      • LinkedHashSet  與輸入順序相同
    • TreeSet 自動排序
  • List 可重複 -> ListIterator較Iterator多了往前走的機制 -hasPrevious() -previous()
    • ArrayList 最基本的list
    • Vector 有thread save機制
Map name value pair
  • HashMap 最基本的HashMap
  • TreeMap 自動排序

留言

這個網誌中的熱門文章

input 陣列 - PHP

要如何在 input 裡面回傳陣列資料呢? 就寫了一個簡單的小範例。 以下是 php 原始碼 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 <?php /** 印出Get裡面的資訊 **/ if ( ! empty ( $_GET )) print_r ( $_GET ); /** 初始資料設定 **/ $id = array ( 0 => '#0001' , 1 => '#0002' ); $data [ $id [ 0 ]] = array ( 'date' => '2012-08-12' , 'note' => '上海出差' ); $data [ $id [ 1 ]] = array ( 'date' => '2012-08-17' , 'note' => '北京出差' ); /** 印出表單資訊 **/ echo "<form method='get'>" ; foreach ( $data as $key => $row ){ echo "<input type='text' name=' { $key } [date]' value=' { $row [ 'date' ] } ' />" ; echo "<input type='text' name=' { $key } [note]' value=' { $row [ 'note' ] } ' />" ; echo "<br />" ; } echo "<input type='submit' value='送出' />" ; e...