![]() ![]() ![]() | Lecture 7 - slide 17 : 41 |
class Linkable {
private Object data;
private Linkable next;
/** Return a Linkable object with null references in both data and next */
Linkable(){
data = null;
next = null;
}
/** Return a Linkable object with null references in next, and the parameter as data */
Linkable(Object data){
this.data = data;
this.next = null;
}
/** Return a Linkable object with first parameter as data and second parameter as next */
Linkable(Object data, Linkable next){
this.data = data;
this.next = next;
}
/** Return the data of this Linkable object */
Object data(){
return (data);
}
/** Return the reference to the next Linkable */
Linkable next(){
return (next);
}
/** Set the data field of this Linkable object */
void setData(Object data){
this.data = data;
}
/** Set the next field of this Linkable object */
void setNext(Linkable next){
this.next = next;
}
} // end Linkable