I'm have written a pseudo code for an algorithm and I would like to draw an activity diagram for it. However, I cannot find any source stating which notation to use for "for loops". I don't suppose it is the decision diamond.
There is an example.
int[] ns = { 1, 4, 9, 16, 25 };
for (int i=0; i<ns.length; i++) {
int n = ns[i];
System.out.println(n);
}

@startuml
start
:int[] ns = {1, 4, 9, 16, 25};
partition for {
:int i=0;
repeat :int n = ns[i];
:System.out.println(n);
backward:i++;
repeat while (i<ns.length)
}
stop
@enduml
While there is special loop task notation in BPMN, there is no special notation for loops in UML Activity Diagrams. The things to use are: decision node and guard condition
See also:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With