Integer[] i = { 1337, 424242 }和int[] i = { 1337, 424242 };分别生成几个对象?那个性能更好,为什么?public class Test { public static void main(String[] args) { Integer[] a = { 1337, 424242 }; int[] b = { 1337, 424242 }; System.out.println(a[0] instanceof Object); // true System.out.println(a[1] instanceof Object); // true System.out.println(b[0] instanceof Object); //编译不通过 System.out.println(b[1] instanceof Object); //编译不通过 }}问题一:性能的话,我感觉,能不用堆就不用堆吧,那么用int性能会更好,不知道这样对不对?还有没有更深层次的考虑呢??问题二:ThreadLocal 和InheritableThreadLocal 区别,分别在哪些场景下使用?
添加回答
举报
0/150
提交
取消