UML Behavioral Modeling
In UML the behavior of a system is defined by a combination of diagrams: state machines, activities and interactions. In addition, behavior can be defined using any textual action language. This action language may also be used to define the elements that comprise a behavior diagram, such as activity action, control flow guards, and transition effects. Snippets can be easily attached to model elements using the Snippet Editor, as shown on the following figures.
The UML behavioral features described above can be used to specify the lifecycle of a class, the implementation of an operation, or can be stand alone model elements. In addition, UML profiles can be used to change the behavior of a UML element by applying stereotypes to UML elements.

Java snippet is attached to an operation

Java code in activity
