0
我正在使用Eclipse Java EE IDE进行Web开发。未使用的类无法在Eclipse中解析
版本:赫利俄斯服务版本2 版本ID:20110218-0911
目前我正在写一个书店项目中,但是编译ShoppingCart.java时,它显示
“ - 类型的java.util。 function.Consumer不能得到解决。这是间接需要的.class文件
- The type java.util.function.Consumer cannot be resolved. It is indirectly referenced from required .class
files
- The type java.util.function.Predicate cannot be resolved. It is indirectly referenced from required .class files
- The type java.util.function.UnaryOperator cannot be resolved. It is indirectly referenced from
required .class files
- The type java.util.Comparator cannot be resolved. It is indirectly referenced from required .class files"
开头引用。 这是Book.java
package bookstore;
import java.io.Serializable;
public class Book implements Serializable {
private static final long serialVersionUID = 1L;
private String isbn;
private String author;
private String title;
private double price;
private int edition;
private String publisher;
private String copyright;
public Book(String isbn, String author, String title, double price, int edition, String publisher, String copyright) {
this.isbn = isbn;
this.author = author;
this.title = title;
this.price = price;
this.edition = edition;
this.publisher = publisher;
this.copyright = copyright;
}
public String getIsbn() {
return isbn;
}
public String getAuthor() {
return author;
}
public int getEdition() {
return edition;
}
public String getPublisher() {
return publisher;
}
public String getCopyright() {
return copyright;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
}
而且ShoppingCart.java
package bookstore;
import java.util.*;
import java.util.ArrayList;
public class ShoppingCart extends ArrayList<Book> {
private static final long serialVersionUID = 1L;
public ShoppingCart() {
}
public void addBook(Book book) {
this.add(book);
}
public Book getBook(int i) {
return this.get(i);
}
public double getTotalPrice() {
double price = 0.0;
for (Book book : this) {
price += book.getPrice();
}
return price;
}
}
我不包括消费,谓语,UnaryOperator和比较器的功能。我发现,在“扩展的ArrayList”