short question. Hopefully it gets answered pretty fast. Lets say I have a singleton like this:
package main.library;
public enum LibrarySingleton {
INSTANCE(new String[][]{});
final String[][] bookStore;
private LibrarySingleton(String[][] bookStore){
this.bookStore = bookStore;
}
}
and a Book class that holds 3 variables:
package main.library;
public class Book{
String author;
String title;
int pages;
@Override public String toString(){
return ("|" + author + "|" + title + "|" + pages + "|");
}
public Book(){
System.out.println("Error: No book information specified");
}
public Book(String author, String title, int pages){
this.author = author;
this.title = title;
this.pages = pages;
}
public String getAuthor(){
return author;
}
public String getTitle(){
return title;
}
public int getPages(){
return pages;
}
}
I'm looking on how to use that singleton as an array holding books. How can I access the books, throw them into the array (singleton), or remove them from the array (singleton)? In case the singleton should be written differently, please correct me, and explain why is it wrong, as I'm not so "premium" with Java yet.
Really hope you guys are going to answer me on that. Just the questions please.