I have a Interface I which has a static function returnbjectsCreated()
Initially class A and B implemented I
But I want to keep track of the objects created.
So I created a class C that implements I ; A and B extends C
I thought of appending the array in defObj in the constructor of C but didn't work as it was final.
public interface I
public static DefObj returnCreatedObjArr()
Each time I create a new object for A or B, it needs to be appended to defObj in the interface.
i.e when I access I.returnCreatedObjArr() it should return all objects created.
What should I do ?
Note: No external packages or java collections can be used
Can you please add a snippet of that? The trouble I am facing right now is as follows :
private Node updateDefObj()
DefObj new DefObj = new DefObj[defObj.length + 1];
System.arraycopy(defObj.length, 0, new defObj.length, 0, defObj.length);
defObj.[defObj.length+1] = this;
defObj = new DefObj.length[defObj.length + 1] ;
defObj = updateDefObj(defObj); }