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.
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:
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.