How to implement Data Structure with custom methods
Hello all
im not sure if the topic is right but what im trying to do is goes like this :
i have Custom Data Structure this custom data structure have basic methods and have no logic
some thing like this :
publicclass MyStruct{
protectedint i ;
protected String j ;
public MyStruct(){
this.i = 0;
this.j =null;
}
publicvoid getID(int i){
this.i = i;
}
publicvoid getID(String i){
this.j = i;
}
}
now say i like to add some logic and some methods to this data structure
BUT ( and here is my problem ) i like to make this addition plug ( i have no other way to describe it )
that is add some kind of class that will extend this class and will add me more possibilities to my data Structures
here im extending the MyStructMethod_1 with MyStruct class but i know its not the right way do to it i just dont know
how to do it , so i have this:
publicclass MyStructMethod_1extends MyStruct{
publicvoid getID(int ii,int jj){
i = ii*jj;
}
publicvoid getID(String ii ,String jj){
j = i+j;
}
}
and from my Main code i could
refer to my MyStruct like this ( again i know it will not work its only so show what i mean )
MyStruct ms = new MyStruct();
ms.getID(2,3);
ms.getID("hello","world");
ms.getID(5);
as you can see im referring to my MyStruct with the methods i defined in the sub class
then i could make many plugble subclass that will extend my MyStruct .
can it be done in java ?
thanks allot

