不兼容的类型-找到java.util.Iterator(Lot),但需要java.util.Iterator(java.lang.String)

不兼容的类型-找到java.util.Iterator(Lot),但需要java.util.Iterator(java.lang.String),java,Java,我目前在迭代集合时遇到问题。当我声明字段和构造函数并尝试输入方法来迭代集合并打印出元素时,会出现以下错误 不兼容的类型-找到java.util.Iterator(Lot),但需要java.util.Iterator(java.lang.String) 这是我的密码 public class Auction { // The list of Lots in this auction. private ArrayList<Lot> lots; // The number that wil

我目前在迭代集合时遇到问题。当我声明字段和构造函数并尝试输入方法来迭代集合并打印出元素时,会出现以下错误

不兼容的类型-找到java.util.Iterator(Lot),但需要java.util.Iterator(java.lang.String)

这是我的密码

public class Auction
{
// The list of Lots in this auction.
private ArrayList<Lot> lots;
// The number that will be given to the next lot entered
// into this auction.
private int nextLotNumber;

/**
 * Create a new auction.
 */
public Auction()
{
    lots = new ArrayList<Lot>();
    nextLotNumber = 1;
}
public void close ()
{
    Iterator<String> it = lots.iterator();
    while(it.hasNext()) {
        System.out.println(it.next());
}
}
公开类拍卖
{
//这次拍卖的拍卖品清单。
私人住宅地段;
//输入的下一批货物的编号
//我参加了这次拍卖。
私有int NEXTLOTTNUMBER;
/**
*创建一个新的拍卖。
*/
公开拍卖()
{
lots=新的ArrayList();
nextLotNumber=1;
}
公众假期结束()
{
Iterator it=lots.Iterator();
while(it.hasNext()){
System.out.println(it.next());
}
}
试试这个

public void close ()
{
    Iterator<Lot> it = lots.iterator();
    while(it.hasNext()) {
        System.out.println(it.next());
}
公共作废关闭()
{
Iterator it=lots.Iterator();
while(it.hasNext()){
System.out.println(it.next());
}
试试这个

public void close ()
{
    Iterator<Lot> it = lots.iterator();
    while(it.hasNext()) {
        System.out.println(it.next());
}
公共作废关闭()
{
Iterator it=lots.Iterator();
while(it.hasNext()){
System.out.println(it.next());
}

Class
Lot
应该实现
toString()
@Zecc它没有必要调用对象的toString(),当然如果它覆盖了它的goodClass
Lot
应该实现
toString()
@Zecc它没有必要调用对象的toString(),当然如果它覆盖了它的good