發表文章

目前顯示的是 2010的文章

[Android] 想在fullscreen上畫出按鈕,應該使用ImageButton還是ImageView呢?

應該使用ImageButton,因為ImageButton不是Button的子類別而是ImageView的,因此所有可在ImageView上用到的好處在ImageButton上都可以使用得到。

[Database] Derby使用筆記

Starts up the Derby engine Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); Creates and connects to a database Connection conn = DriverManager.getConnection("jdbc:derby:" + dbName + ";create=true"); // 若要自行手動控制transaction, 要將JDBC中預設的autocommit功能關掉. conn.setAutoCommit(false); Creates a table // 可針對該資料庫重複使用的Statement物件 Statement stmt = conn.createStatement(); // 建立名為location的資料表 stmt.execute("CREATE TABLE location(num int, addr varchar(40))"); Inserts data // 當重覆執行SQL敘述時, 建議使用PreparedSstatement(可以不需要每次都recompileSQL敘述) PreparedStatement pStmt = conn.prepareStatement("INSERT INTO location VALUES(?, ?)"); pStmt.setInt(1, 1956); pStmt.setString(2, "Min-Sheng East Road"); pStmt.executeUpdate(); Updates data PreparedStatement psUpdate = conn.prepareStatement("UPDATE location SET num=?, addr=? where num=?"); psUpdate.setInt(1, 300); psUpdate.setString(2, "Cheng-Guong ...

[Java] 何時該使用LinkedList? (與ArrayList的效率比較)

根據網路上的 這篇測試 顯示出了以下結果: 多次建立並刪除第一個元素: ArrayList 花費 4346 毫秒 LinkedList 花費 0 毫秒 多次建立並刪除串列中的中間元素: ArrayList 花費 2104 毫秒 LinkedList 花費 26728 毫秒 多次建立並刪除串列的最後一個元素: ArrayList 花費 731 毫秒 LinkedList 花費 1242 毫秒 因此大概可以得出一個結論:在Java語言中,不管你想實作怎樣的資料結構, 為了效率的考量,不要使用LinkedList 。

[Java] HashTable和HashMap的不同

HashTable和HashMap的不同主要有四種 一、 HashTable 是繼承java.util.Dictionary HashMap 是繼承java.util.AbstractMap Dictionary 是舊的class, 【DOC】NOTE: This class is obsolete. New implementations should implement the Map interface, rather than extending this class. java.util.AbstractMap 已經implements Map Interface,因此繼承它的class 只需要實作它的method就可以實作出需要的Map (例如get,put,entrySet method) 可參:http://java.sun.com/j2se/1.4.2/docs/api/java/util/AbstractMap.html java.util.Dictionary 並沒有去Implements Map Interface,HashTable是另外去實作Map interface,也因此HashTable能被算在Java Util Framework中。 ...