網頁

2014年11月27日 星期四

[Android]Eclipse 快捷鍵

ctrl + / 註解 (取消註解)

ctrl + shift + O 自動匯入所欠缺的類別

alt + ← 移至上一次游標所在位置

alt + → 移至下一次游標所在位置

ctrl + shift + P 移至匹配的括號

ctrl + Q 移至上一次編輯的位置

ctrl + shift + L 列出所有快速鍵

alt + shift + R 修改變數名稱

alt + / 程式碼輔助

ctrl + D 刪除單一行

ctrl + shift + F 程式碼自動排版

ctrl+ L 移至指定行數

ctrl+shift+Y 小寫字母

ctrl+shift+X 大寫字母

ctrl+alt+/ 自動完成

ctrl+3 搜尋在分頁中的檔案

ctrl+shift+U

alt+shift+J 加入Java doc說明

ctrl+* Expand All

ctrl+shift+T search

ctrl+shift+R Open Resource

ctrl+F6 上次使用的檔案

ctrl+alt+H 顯示繼承架構

ctrl+shift+G references in workspace

ctrl+F11 快速執行

F11 快速執行(Debug模式)

ctrl+K 快速搜尋選取的字

ctrl+1 自動修復

[Android]Queue(FIFO)

Reference:
Queue | Android Developments
http://developer.android.com/reference/java/util/Queue.html

http://jhengjyun.blogspot.tw/2010/09/java-queue.html

不要使用原始的add()和remove(),在Queue中會丟出exception,
以offer()和poll()來代替
方法傳回值說明
offer(E o)boolean加入物件
peek()E取得物件,若空傳回null
element()E取得物件,若空傳回例外
poll()E取得物件,並移除該物件,若空傳回null
remove()E取得物件,並移除該物件,若空傳回例外
範例: import java.util.*; 
public class Ex { 
    public static void main(String[] args) { 
        Queue q = new LinkedList(); 
        q.offer("First"); 
        q.offer("Second"); 
        q.offer("Third"); 
        Object o; 
        System.out.println(q.toString()); 
        while((= q.poll()) != null) { 
            String s = (String)o; 
            System.out.println(s); 
        } 
        System.out.println(q.toString()); 
    } 
}