Nested Classifier

A class or interface in the UML could be used as a namespace for other classifiers including other classes, interfaces, use cases, etc. This nesting of classifiers limits the visibility of the classifier defined in the class or interface to the scope of the namespace of the container. It could be used for reasons of information hiding.

Class or interface could nest (contain) other classifiers.

Class or interface could nest (contain) other classifiers.

Nested classifier is a classifier that is defined within the (namespace of) class or interface. Note, that UML 2.x specification uses "defined within", "nested within" and "owned by" as synonyms which causes a bit of confusion. Relationship between the namespace and nested classifier is called namespace ownership.

Now obsolete UML 1.4.2 Specification defined nested class as a class declared within another class and belonging to the namespace of the declaring class. Relationship between those classes was called "namespace owned element association".

Nested classifier, e.g. nested class, nested interface, or nested use case could be used like any other classifier but only inside the containing class or interface.

Per UML 1.4.2 a declaring (nesting) class and a nested class could be shown connected by a line, with an "anchor" icon on the end connected to the declaring class. An anchor icon is a cross inside a circle.

UML 2.x specifications - including the recent UML 2.4.1 - describe nesting of classifiers within structured classes without providing explicit notation for the nesting. Note, that UML's 1.4 "anchor" notation is still used in one example in UML 2.4.x for packages as an "alternative membership notation" and without providing any other details or explanations.

Class LinkedList is nesting the Element interface. The Element is in scope of the LinkedList namespace.

Class LinkedList is nesting the Element interface.
The Element is in scope of the LinkedList namespace.

Class InnerOddIterator is nested by DataStructure class. Class DataElement is aggregated by DataStructure class.

Class InnerOddIterator is nested by DataStructure class.
Class DataElement is aggregated by DataStructure class.

The nesting (owning) of a use case by a classifier is represented using the standard notation for nested classifiers.