How to judge a class is useless in java
This article shows you how to judge a class is a useless class in java, the content is concise and easy to understand, it can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
The method area mainly collects useless classes, so how to judge that a class is useless?
It is relatively simple to determine whether a constant is an "obsolete constant", while the conditions for determining whether a class is a "useless class" are much harsher. A class needs to meet the following three conditions to be considered a "useless class":
All instances of the class have been recycled, that is, no instances of the class exist in the Java heap.
The ClassLoader that loaded the class has been recycled.
The corresponding java.lang.Class object of this class is not referenced anywhere, and its methods cannot be accessed anywhere through reflection.
The virtual machine can recycle the useless classes that meet the above three conditions. Here we only say "yes", not that it will be recycled if it is not used as an object.
The above is how to determine whether a class is useless in java. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.