Is there any way to do the following without either invoking garbage collection or increasing heap size to avoid eventual GC?

```
List<Long> someList = new ArrayList<Long>();
someList.add(1l);
someList = new ArrayList<Long>(); //Will this cause GC of the old `someList`?

```

So what I'm asking is if the original `ArrayList` will get deleted (and eventually GCd)? If so, how do I remedy this such that I can overwrite the original list without GCing?
['https://Stackoverflow.com/questions/21041564', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2763361/']
The older `ArrayList` will become eligible for garbage collection on line 3, provided there is no other reference pointing to it, as it seems is the case here. However, it isn't guaranteed to be GCed right away.

If you want to avoid extra creation of the `ArrayList`, you can simply clear it by using `List#clear()` method:

```
someList.clear(); 

```
I assume by your question you want to keep a reference to the old list (and also its content, otherwise whats the point)? 

If so then just add a reference to it before reassigning:

```
List<Long> someList = new ArrayList<Long>();
someList.add(1L);
List<Long> oldList = someList;
someList = new ArrayList<Long>();

```