Click here to Skip to main content
15,175,525 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
SQL
public class SportCarHouse implements CarIterator {

      List sportsCars;
      public List getCars() 
      {
            return sportsCars;
      }
      public Iterator createIterator() 
      {
            return sportsCars.iterator();
      }
}


I've got the above code which implements the Iterator interface, but I get the following errors.

CSS
C:\Documents and Settings\20818781\Desktop\Pattern_iterator\SportCarHouse.java:4: cannot find symbol
symbol  : class List
location: class SportCarHouse
      List sportsCars;
      ^
C:\Documents and Settings\20818781\Desktop\Pattern_iterator\SportCarHouse.java:19: cannot find symbol
symbol  : class List
location: class SportCarHouse
      public List getCars()
             ^
2 errors
Posted

1 solution

As with the Iterator class before, try importing the List class:
import java.util.List

Oh, wait, scratch that. Even better:
import java.util.*;
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900