阅读背景:

在Java中使用arraylist对象的方法

来源:互联网 
public class Book
{
private String isbn, author, area;
private int length;
public Book(String isbn, String author, String area, int length)
{
    this.isbn=isbn;
    this.author=author;
    this.area=area;
    this.length=length;
}
public boolean isLong()
{
    if (length>500)
        return true;
    else 
        return false;
}    
} 
public class BookCollection

{
 private ArrayList<Book> bookList = new ArrayList<Book>();


public BookCollection()throws IOException
{
    Scanner fileScan;
    String oneLine;
    String isbn, author, area;
    int length;

    fileScan = new Scanner (new File("books.txt"));
    while (fileScan.hasNext())
    {
        isbn=fileScan.next();
        author=fileScan.next();
        area=fileScan.next();
        length=fileScan.nextInt();
        bookList.add(new Book(isbn, author, area, length));
    }
}
 public class TestBookCollection
{

public static void main (String[] args)throws IOException
{
    BookCollection books = new BookCollection();
    System.out.println(books);


}
}
public class Book
{
private String isbn, author



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: