原创 【Android實例】1像素進程保活

1 進程保活 1像素保活原理是,監聽手機屏幕狀態,如果手機黑屏,則啓動一個1像素的Activity,減少該應用被回收的機率;在屏幕亮的時候,就關閉該Activity。1像素保活對某些手機不管用,親測兩款手機:紅米5Note(Android

原创 【ArrayList源碼】get源碼及使用

1 get源碼 /** * Returns the element at the specified position in this list. *返回列表中指定位置的元素 * @param inde

原创 【Android源碼】setContentView流程

1 Activity中的setContentView 我們都知道Activity裏,setContentView是我們用來加載佈局的,那麼它裏面的源碼是怎麼樣的呢?先看下父類Activity裏面的setContentView方法體

原创 【Thread源碼】join源碼及使用

1 join源碼 /** * Waits for this thread to die. *等待當前線程死亡(指的是主線程等待當前線程死亡) * <p> An invocation of this method

原创 【ArrayList源碼】add方法(自動擴容)

1 add源碼解析 在【ArrayList源碼】ArrayList構造方法中,ArrayList無參構造方法默認是一個空數組,但註釋說是容量爲10的數組。其實ArrayList的容量是在調用add方法時初始化的。add方法是List接口中聲

原创 【ArrayList源碼】ArrayList構造方法

ArrayList簡介 ArrayList稱爲數組鏈表,它是繼承AbstractList,並實現了List、RandomAccess、Cloneable和Serializable接口 public class ArrayList<E> ex

原创 【Java】Java中的==

Java中的== Java中的==表示的是什麼呢?有時候很令人費解。比如,以下例子輸出是什麼? // 例一 String str = "wo"; String str1 = "wo";

原创 【String源碼】equals解析與使用

本文基於JDK1.8 1 String中equals源碼分析 String是final類型,它不可被繼承。String的equals方法如下所示: /** * Compares this string to the spe

原创 【ArrayList源碼】indexOf源碼及使用

1 ArrayList的indexOf方法 ArrayList的indexOf源碼如下: /** * Returns the index of the first occurrence of the specified eleme