Java Reference
In-Depth Information
Display 15.9
A Sample Class for the Data in a Generic Linked List
1
public
class
Entry
2{
3
private
String item;
4
private
int
count;
5
public
Entry(String itemData,
int
countData)
6
{
7
item = itemData;
8
count = countData;
9
}
10
public
String toString( )
11
{
12
return
(item + " " + count);
13
}
14
public
boolean
equals(Object otherObject)
15
{
16
if
(otherObject ==
null
)
17
return
false
;
18
else
if
(getClass( ) != otherObject.getClass( ))
19
return
false
;
20
else
21
{
22
Entry otherEntry = (Entry)otherObject;
23
return
(item.equals(otherEntry.item)
24
&& (count == otherEntry.count));
25
}
26
}
<
There should be other constructors and methods, including accessor and
mutator methods, but we do not use them in this demonstration.
>
27
}