:( 各位高手大家好,本人刚学Java,对很多东西都不是很清楚,这几天我照着书上敲了好几个程序,放到Eclipse里去编译(注:我的Eclipse是3.2中文版的),老是显示出错,程序如下(出问题的语句用红色标出):
/*!Begin Snippet:file*/
import java.util.*;
import java.text.*;
/**
- Maintains a collection of {@link Borrower} objects. *
- @author XXX
- @version 1.0.0
-
@see Borrower
*/
public class BorrowerDatabase implements [color=red]Iterable[/color] {//问题是:放到第一个上时显示,类型Iterable不是通用的;不能使用参数将其参数化!!!
//放到第二个,即上时显示,语法错误,仅当源级别为5.0时已参数化的类型方可用。/* Collection of <code>Borrower</code> objects.*/
[color=red]private ArrayList borrowers;[/color]
//问题是:放到第一个上时显示,类型ArrayList不是通用的;不能使用参数将其参数化!!!
//放到第二个,即上时显示,语法错误,仅当源级别为5.0时已参数化的类型方可用。/**
- Constructs an empty collection of {@link Borrower}
-
objects.
*/
public BorrowerDatabase() {this.borrowers = new ArrayList();
}
/**
- Adds a {@link Borrower} object to this collection. *
-
@param borrower the {@link Borrower} object.
*/
public void addBorrower(Borrower borrower) {this.borrowers.add(borrower);
}
/**
- Returns an iterator over the borrowers in this database. *
-
return an {@link Iterator} of {@link Borrower}
*/
public [color=red]Iterator [/color] iterator() {//问题同上~~~~~~~~~~~
return this.borrowers.iterator();
}
/**
- Returns the {@link Borrower} object with the specified
-
id
. * - @param id the id of the borrower.
- @return The {@link Borrower} object with the specified id.
- Returns
null
if the object with the -
id is not found.
*/
public Borrower getBorrower(String id) {for (Borrower borrower : this.borrowers) {
if (borrower.getId().equals(id)) {return borrower; }
}
return null;
}
/**
- Returns the number of {@link Borrower} objects in this collection. *
-
@return the number of {@link Borrower} objects in this collection.
*/
public int getNumberOfBorrowers() {return this.borrowers.size();
}
}
/*!End Snippet:file*/
注:类Borrower已存在并成功编译。
这是为什么啊,我已经在网上查了很久,也问了很多人,但没人知道,郁闷至极~~~~~~~~~
望各位能够不吝赐教,小生将感激不尽啊!!!
[b]问题补充:[/b]
1.Borrower类已存在啊,并且已引入到该包下面,但还是不行,Eclipse一直报错,哎~~~~~
2.依据lixc的答复我也试了,但没发现Compiler comliance level啊!真是惭愧,能否麻烦你讲具体点在哪?谢谢了~~~~~~~~~