731
{
intindex = 0 ;
while(index < numItems && listItems[index].compareTo(item) != 0 )
index++;
return(index < numItems);
}
public voidinsert(String item)
// If the list is not full, put item in the last position in the list;
// otherwise, list is unchanged
{
if(!isFull())
{
listItems[numItems] = item;
numItems++;
}
}
public voiddelete(String item)
// Remove item from the list if it is there
{
intindex = 0 ;
booleanfound = false;
while(index < numItems && !found)
{
if(listItems[index].compareTo(item)== 0 )
found = true;
else
index++;
}
if(found)
{
for(intcount = index; count < numItems- 1 ; count++)
listItems[count] = listItems[count+ 1 ];
numItems--;
}
}
}
2.public classListWithSort extendsUnsortedList
{
// Allows the items in the list to be rearranged into ascending order.
// This order is not preserved in future insertions.