One confusion you may encounter is that the main method can be called even if it is not the main object. This is because it is a static method. Similarly, "Integer x" exists only as a field in the main object. Therefore, when you create a new Core Object m, you also create an integer mx as part of m. Then, when you set m to null, the object that was previously mentioned by m is garbage and can be collected.
Now that it is assembled, this is a completely different matter. In fact, there are no guarantees; however, since its use has been so localized, it will almost certainly be taken care of the next minor assembly / cleaning / selection of your favorite terminology.
source share