Compliation Error: Recompile with -Xlint:unchecked for details

I am new to Java and am working through Sams Teach Yourself Java2 book. One of the examples gave me a compilation error. The problem code follows:

C:\Java_Work\com\ramyam\ecommerce>java c Storefront.java

Note: Storefront.java uses unchecked or unsafe operations.

Note: Recompile with -Xlint:unchecked for details.

package com.ramyam.ecommerce;

import java.util.*;

publicclass Storefront{

private LinkedList catalog =new LinkedList();

publicvoid addItem(String id, String name, String price, String quant){

Item it =new Item(id, name, price, quant);

catalog.add(it);

}

public Item getItem(int i){

return (Item)catalog.get(i);

}

publicint getSize(){

return catalog.size();

}

publicvoid sort(){

Collections.sort(catalog);

}

}

I think it has something to do with the collections class being outdated. Does anyone have any idea how to fix this?

Thanks in advance,

georgina

[1853 byte] By [georgiebona] at [2007-11-27 9:41:52]
# 1

The book probably was published before Java had Generics. You can do as the error message says and recompile with the Xlint:unchecked option. Basically, you need to specify the type of objects you are putting into the LinkedList, something like private LinkedList<Item> catalog = new LinkedList<Item>();

This may cause you other errors.........

atmguya at 2007-7-12 23:21:40 > top of Java-index,Developer Tools,Java Compiler...