Providing Java library, but hiding some classes

后端 未结 6 1439
鱼传尺愫
鱼传尺愫 2020-12-15 08:32

I am developing an application in Java ME that I want to provide as a library. Is there no way to hide classes that I don\'t want everyone to use, but is essential still in

6条回答
  •  不知归路
    2020-12-15 09:12

    Yes, there is.

    Simply don't declare those classes public. In other words, omit the public keyword like so:

    class Internal { // rather than "public class Internal"
        ...
    }
    

    By default, classes are only accessible within the package where they are defined.

提交回复
热议问题