Are static fields open for garbage collection?

前端 未结 6 1060
谎友^
谎友^ 2020-11-22 13:02

Given an hypothetical utility class that is used only in program setup:

class MyUtils {
   private static MyObject myObject = new MyObject();
   /*package*/s         


        
6条回答
  •  忘了有多久
    2020-11-22 13:56

    I think this answers your question - basically not unless the class comes from a special class loader and that unloads the class.

提交回复
热议问题