Is there any way to allow an array to store multiple data types
in
Programming Questions
•
1 year ago
I'm aware that there are some work arounds to this but nothing that I can come up with can really work the way I would like it to.
Lets say i want to store both of the below classes (A and B) in the same array, how would I do it?
- class ALL{
- String type = "Basic";
- my_id=current_id;
- ALL(){ array[my_id]=this; current_id++;}
- }
- class A extends ALL{
- String type = "A type";
- my_id=current_id;
- A(){ array[my_id]=this; current_id++;}
- }
- class B extends ALL{
- String type = "B type";
- my_id=current_id;
- A(){ array[my_id]=this; current_id++;}
- }
The above code is pretty much how I am going about doing it at the moment but it is giving me all sorts of problems.
Any ideas??
Thanks
1