梦土上

此博客停止更新,请移步本人网站 http://lilei.work

博客园 首页 新随笔 联系 订阅 管理
  1. View.findViewById采用深度遍历,找到第一个匹配的控件
  2. Integer Cache
     1     public static void testIntegerCache() {
     2         Class cache = Integer.class.getDeclaredClasses()[0];
     3         try {
     4             Field f = cache.getDeclaredField("cache");
     5             f.setAccessible(true);
     6             Integer[] array = (Integer[]) f.get(cache);
     7             array[130] = array[131];
     8         } catch (Exception e) {
     9             e.printStackTrace();
    10         }
    11         System.out.printf("1+1=%d", 1+1);
    12     }
    View Code
  3. 上面关键在于Integer.valueOf()方法
    1     public static Integer valueOf(int i) {
    2         if(i >= -128 && i <= IntegerCache.high)
    3             return IntegerCache.cache[i + 128];
    4         else
    5             return new Integer(i);
    6     }
    View Code

     

     

posted on 2014-06-04 14:03  猫之歌  阅读(254)  评论(0编辑  收藏  举报