S
sayoyo
Hi Guys,
I have to implement a design in Java which is a collection class
gathers several units of the same class.
I was thinking about two ways to implement it. the first is to create
two class: the collection class and the unit class. The second one is
to create only one unit class but, the all units(whole collection) are
stored into the class variable (static) of the unit class.
And I have no idea which design is better in term of memory used,
speed, etc...
If someone has an idea????? Thanks you very much!!!!!!
Sayoyo
class unitSet{
private HashMap setOfUnit = null;
unitSet(){
setOfUnit = new HAshMap(20);
}
addUnit()....
removeUnit()....
setUnit().....
}
class unit{
unit(){
}
}
******** OR ***********
class unit{
static private HashMap setOfUnit = nll;
static{
setOfUnit = new HAshMap(20);
}
static addUnit()...
static removeUnit()...
static setUnit()...
unit(){
}
}
I have to implement a design in Java which is a collection class
gathers several units of the same class.
I was thinking about two ways to implement it. the first is to create
two class: the collection class and the unit class. The second one is
to create only one unit class but, the all units(whole collection) are
stored into the class variable (static) of the unit class.
And I have no idea which design is better in term of memory used,
speed, etc...
If someone has an idea????? Thanks you very much!!!!!!
Sayoyo
class unitSet{
private HashMap setOfUnit = null;
unitSet(){
setOfUnit = new HAshMap(20);
}
addUnit()....
removeUnit()....
setUnit().....
}
class unit{
unit(){
}
}
******** OR ***********
class unit{
static private HashMap setOfUnit = nll;
static{
setOfUnit = new HAshMap(20);
}
static addUnit()...
static removeUnit()...
static setUnit()...
unit(){
}
}