class Widget {
static private int widgetCount = 0;
public String wName;
int wNumber;
private static int addWidget() {
return ++widgetCount;
}
public Widget() {
wNumber = addWidget();
}
}
A. Each Widget gets a unique wNumber that reflects the order in which the Widgets were created.
B. Each Widget gets a wNumber, but you cannot guarantee that the number will be unique.
|