我正在学习Java的入门课程,我正在建立一个小型图书馆系统,让图书管理员可以添加书籍,列出所有书籍并搜索特定书籍.
它现在正在运作,但在ArrayList一本书中只有标题.我想在图书馆中添加ISBN,作者,出版年份及其当前状态.如何在同一个中添加变量ArrayList?以下是我的ArrayList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
//Array form available books
public final class ListBook {
public static List<String> VALUES = new ArrayList<String>(Arrays.asList(
new String[] {"Book1","Book2","Book3","Book4"}
));
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,另一个重要的类允许图书馆员添加一本新书;
public class InsertBook {
// variables for the book info
public String name_book;
// Importing the list of books
ListBook lb = new ListBook();
// variable for the list of books
private int x;
// Constructors
Scanner input_name = new Scanner(System.in);
public void insertDataBook() …Run Code Online (Sandbox Code Playgroud)