listitem.java
来自「Beginning Java 2, SDK 1.4 Edition Exerci」· Java 代码 · 共 31 行
JAVA
31 行
// Chapter 6 Exercise 5
class ListItem {
protected ListItem previous;
protected ListItem next;
private Object data;
// Constructors:
// Default constructor - sets all references to null:
public ListItem() {
previous = next = null;
data = null;
}
// Constructor normally used - sets data to refer to the Object passed:
public ListItem(Object data) {
this.data = data;
previous = next = null;
}
// Overrides the default toString in Object by the toString of data:
public String toString() {
return data.toString(); // Returns a string referring to the data,
} // not to the ListItem.
// Returns the class of the data object (not of the Item itself):
public Class getItemClass() {
return data.getClass();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?