首页 > 其他 > 详细

挖坑神器

时间:2019-11-15 19:25:25      阅读:83      评论:0      收藏:0      [点我收藏+]
Class<?> clazz = Class.forName(
"java.lang.Integer$IntegerCache");
Field field = clazz.getDeclaredField("cache");
field.setAccessible(true);
Integer[] cache = (Integer[]) field.get(clazz);

// Rewrite the Integer cache
for (int i = 0; i < cache.length; i++) {
cache[i] = new Integer(
new Random().nextInt(cache.length));
}
for (int i = 0; i < 10; i++) {
System.out.println((Integer) i);
}

挖坑神器

原文:https://www.cnblogs.com/wangchaoyu/p/11868813.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!