UML class diagram for string array

SuchZen picture SuchZen · Mar 2, 2013 · Viewed 10k times · Source

In UML how should we show a method which return string array in UML method that looks like this

public String[] delete(int col, int row){}

Is this representation correct?

+delete(col: int; row: int): String[]

Answer

Martin Spamer picture Martin Spamer · Mar 5, 2013

That is ok, but ideally you should include the bounds in OCL. e.g.

+delete(col: int, row: int): string[0..*]

This is not an array but a 'bounds' so [0..] is zero to infinite strings. [0..1] Zero or one strings. [1..] 1 to infinite strings.

In this case string is the OCL type not a Java String object, others are Bag, Set etc.