Problem Statement:
Problem Statement:
/* TailList.java */
public class TailList extends SList{
private SListNode tail;
public TailList(){
tail = null;
}
/**
* insertEnd() inserts item "obj" at the end of this list.
* @param obj the item to be inserted.
**/
public void insertEnd(Object obj) {
if(this.size > 0){
SListNode node = new SListNode(obj);
this.tail.next = node;
this.tail = node;
}else{
this.head = this.tail = new SListNode(obj);
}
this.size++;
}
/**
* insertFront() inserts item "obj" at the beginning of this list.
* @param obj the item to be inserted.
**/
public void insertFront(Object obj){
super.insertFront(obj);
if(size == 1){
tail = head;
}
}
}
Does TailList class inheritance relation with SList implementation class looks fine(within same package)? How do iI know whether SList class is specifically designed for inheritance, as mentioned in below para?
"ItIt is safe to use inheritance within a package, where the subclass and the superclass implementations are under the control of the same programmers. It is also safe to use inheritance when extending classes specifically designed and documented for extension (Item 17). Inheriting from ordinary concrete classes across package boundaries, however, is dangerous. As a reminder, this book uses the word “inheritance” to mean implementation inheritance (when one class extends another). The problems discussed in this item do not apply to interface inheritance (when a class implements an interface or where one interface extends another)."
Note: I am Java beginner.