In my program, I have several class variables whose access specifier is known as private package.

The default accessor specifier in Java is known as private package where it is accessible within the package which the class belongs to.

For the UML class diagram , should I label these variables as public or private? I can't decide because of this concept of private package.

  • 1
    Why don't you label them private package? That's what the accessor specifier is, right? – Robert Harvey Apr 7 '14 at 2:22
  • @RobertHarvey For UML diagram , by convention , there is only public , private ,protected which is represented by + , - , # respectively. There is no symbol to represent private package – Computernerd Apr 7 '14 at 8:11

If the tool you use for drawing the UML diagrams doesn't provide the (language specific) access specifier that you need, you can still draw a useful class diagram.

The easiest way is just to leave out all the access specifiers. This doesn't mean that everything is now public, but rather that the diagram doesn't tell you if the members are public, private, package private or something else.

If you do want to show access specifiers, you also could label the package private members as protected members. While technically incorrect, protected access is the closest in meaning to package private access and is usually used only very little, so you could just add a note to your diagram that the protected access specifier should be read as package private.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.