a generalized list structure can be declared in C as follows:
typedef struct element{
bool sign;
union{
char data;
element* link;
};
element* link;
}
as you see in this approach an element can have either "data" or "element* link"(the last link is included in every element) and union works great in this point.
If we try to move this code to Java,how can we find the corresponding of the union part?
Should we use inheritance as a parent class and two subclasses,one of them has data other has link?Would it be a good approach? Or if are there any better approachs you can suggest,please let me know...