use*_*361 1 java garbage-collection arraylist immutability
有没有办法在不调用垃圾收集或增加堆大小的情况下执行以下操作以避免最终的GC?
List<Long> someList = new ArrayList<Long>();
someList.add(1l);
someList = new ArrayList<Long>(); //Will this cause GC of the old `someList`?
Run Code Online (Sandbox Code Playgroud)
那么我要问的是原件ArrayList是否会被删除(最终是GCd)?如果是这样,我该如何解决这个问题,以便我可以在没有GCing的情况下覆盖原始列表?