java. Lang. void class source code analysis

When viewing the ThreadGroup in the source code, I see a piece of code, which is as follows:

This method is used to check the access permission of the parent, and then directly return null. The return type of the method is void. Originally, the void class was a wrapper class of void class, but check the value of the void class

It is found that this is not the case after the source code. The source code of void class is as follows:

In the top note, it describes

The meaning of this paragraph is that the void class is a non instantiatable placeholder class that holds a reference to the class object that identifies the Java keyword void.

And its constructor is private, and it is noted that:

Final indicates that this class is not allowed to be inherited by other classes.

That is, this class cannot be instantiated.

The void class may not work in itself, but it is only a placeholder class. That is, the void class itself is only a placeholder class and cannot be instantiated. It is mostly used as a placeholder in generic types.

summary

The above is about Java Lang. void class source code analysis of all the contents, I hope to help you. Interested friends can refer to: ratelimiter source code analysis, queue source code based on zookeeper, spring MVC executing method source code analysis after startup, etc. if you have any questions, you can leave a message at any time, and the editor will reply to you in time.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>