Java – how to hide public methods?

There is a method in my static state machine that is used only once when my application starts for the first time This method needs to be exposed, but I still want to hide it Is there any way to use annotations or some way to hide the method in the rest of the project?

Solution

Once you declare the public method, it will become part of your class contract You cannot hide it because all class users want this method to be available

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
分享
二维码
< <上一篇
下一篇>>