Java UML diagram question
I have a java program to write and the professor gave us a UML diagram to follow. It all makes sense except for the part where there are dollar signs. What do these dollar signs mean? Here's what it looks like:
- firstName : String The wrestler’s first name.
- lastName : String The wrestler’s last name.
- weight : double The wrestler’s weight.
- grade : int The wrestler’s grade expressed as a number.
$sortKey int A class-level variable used to specify how all Wrestler objects should be sorted.
$COMPARE_BY_NAME : int = 1 A class-level constant used to specify that Wrestlers should be sorted by last name.
Do these dollar signs indicate constants? If so, then why does this method have a dollar sign in front of it too?
$setKey(int):void A class-level method used to set the sort key for all Wrestler objects.
Re: Java UML diagram question
The dollar sign ($) is an old way of indicating static methods or variables. So, while you will create instances of the wrestler object, the variable sortKey and the named constant COMPARE_BY_NAME will not be created for every instance. Instead, this variable and constant will only exist once for the entire class (these are called static variables).
Hopefully I explained that well...
By the way, after researching I found out that the new convention for showing static variables or methods in a UML is to underline them. Putting a $ in front of them is now outdated. ;D