Operations are implementations of functions or queries that an object might be called to perform. A well-defined operation does only one thing.
For example, you can make a Cart class responsible for adding and removing merchandise that a client plans to buy. You can then add an addItem( ) operation that adds merchandise to the cart and a removeItem( ) operation that removes merchandise.
Operations are shown in the operation compartment of a classifier
in a class diagram. Operations that are defined in the scope of the
class, that is static, are shown as underlined. The visibility styles
of operations can be represented as text symbols (such as "+") or
icons (such as
).
The following figure illustrates how operations are represented with visibility icons in class diagrams.
| Java source code | UML visual representation |
![]() |
![]() |