In Unified Modeling Language (UML) class diagrams, an operation requests a service that a classifier or an instance of a class is called to perform. Operations are contained by classes and interfaces. A classifier can have any number of operations or none at all.
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.
In UML class diagrams, Java™ methods map to UML class operations (behaviors).
Operations are shown in the operation compartment of a shape in a UML 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 visualization |
![]() |
![]() |