I was looking for information about objects, and on one site I found that
If you simply create an object and do not assign it to any variable, the Java machine will create it and immediately declare it garbage (unused object). And after a while, remove it in the process of "garbage collection."
Does this work if I use the collection?
ArrayList.add(new Object(...)) Because I can continue to use it after adding such an instance to ArrayList.