- View.findViewById采用深度遍历,找到第一个匹配的控件
- 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 }
- 上面关键在于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 }