/** A generic class for pairs. * * <p><b>This is NOT part of any supported API. * If you write code that depends on this, you do so at your own risk. * This code and its internal interfaces are
感覺在設計模式當中,很多很多地方都要用到反射。尤其是從設定檔當中讀取資訊,並使用這個資訊來動態載入。反射的應用特別常見,這裡再一次的討論反射和相關概念。 ClassLoader的類載入機制: l Java當中的類不是一次性都載入到記憶體當中 l 而是需要的時候才動態載入到記憶體當中,也就是說是運行期間的動態載入。 l 靜態語句是在載入後執行一次,而且執行一次 l Dynamic語句塊每次new新的對象都會執行。
一。類如下。 public class Calculator2{ private int add(int a,int b){ return a+b; } } 二,在同一個包中另一個類下調用方法add如下: public class Test {public static void main(String[] args){ Calculator2 calculator2 = new Calculator2();
設定使用3G資料功能: 從原始碼看到隱藏的API(ConnectivityManager.java): /** * Sets the persisted value for enabling/disabling Mobile data. * * @param enabled Whether the mobile data connection should be * used or not. * @hide *
JAVA反射機制基礎: 參考:http://lavasoft.blog.51cto.com/62575/43218/ http://java.ccidnet.com/art/3539/20070924/1222147_1.html JAVA invoke的調用: 有如下的類 public class ClassA{ private int Method1(String[] strs){ int num=0; for(String str:strs)
直接上代碼: 這是一個比較類 public class ComparatorNetInfoResDto implements Comparator { @Override public int compare(Object o1, Object o2) { NetInfoResDto netInfoResDto1 = (NetInfoResDto)o1; NetInfoResDto netInfoResDto2 = (NetInfoResDto)o2; int