My class only compiles in Java 1.6 and not in Java 1.5

Hi, my java class wont compile in java 1.5, it only compiles in Java 1.6. How can i compile the following?
import java.util.*;
public class ShoppingBasket
     Vector products;
     public ShoppingBasket() { products = new Vector(); }
     public void addProduct(Product product)
     boolean flag = false;
     for(Enumeration e = getProducts(); e.hasMoreElements();)
          { Product item = (Product)e.nextElement();
               if(item.getId().equals(product.id))
               {flag = true; item.quantity++; break; }
          if(!flag){ products.addElement(product);}
     public void deleteProduct(String str)
          for(Enumeration e=getProducts();
          e.hasMoreElements();)
          { Product item = (Product)e.nextElement();
               if(item.getId().equals(str))
               {products.removeElement(item); break; }
     public void emptyBasket(){products = new Vector();}
     public int getProductNumber(){ return products.size();}
     public Enumeration getProducts() { return products.elements(); }
     public double getTotal()
     Enumeration e = getProducts();
     double total; Product item;
     for(total=0.0D;e.hasMoreElements();     total+= item.getTotal())
     {item = (Product)e.nextElement(); }
     return total;
}It should link with a class called Product which compiles fine... the errors i get are below:
K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
ket.java:6: cannot find symbol
symbol  : class Product
location: class ShoppingBasket
        public void addProduct(Product product)
                               ^
K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
ket.java:10: cannot find symbol
symbol  : class Product
location: class ShoppingBasket
                { Product item = (Product)e.nextElement();
                  ^
K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
ket.java:10: cannot find symbol
symbol  : class Product
location: class ShoppingBasket
                { Product item = (Product)e.nextElement();
                                  ^
K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
ket.java:20: cannot find symbol
symbol  : class Product
location: class ShoppingBasket
                { Product item = (Product)e.nextElement();
                  ^
K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
ket.java:20: cannot find symbol
symbol  : class Product
location: class ShoppingBasket
                { Product item = (Product)e.nextElement();
                                  ^
K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
ket.java:35: cannot find symbol
symbol  : class Product
location: class ShoppingBasket
        double total; Product item;
                      ^
K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
ket.java:36: inconvertible types
found   : <nulltype>
required: double
        for(total=0.0D;e.hasMoreElements();     total+= item.getTotal())
                                                                     ^
K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
ket.java:37: cannot find symbol
symbol  : class Product
location: class ShoppingBasket
        {item = (Product)e.nextElement(); }
                 ^
8 errors

fahafiz wrote:
ah, so should i put the classes into the folder which the classpath is assigned to?More likely you should assign your classpath to whatever folder your classes are in.
Put your files where they make sense, and then fill in classpath accordingly:
javac -classpath classpath MyFile.java(I think, it's been a while since I compiled from the command-line, see http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javac.html)

Similar Messages

Maybe you are looking for