If I delete the "public BookManager(){ }".The code report error:"Can't solve the charactor tbook"
It means I must place the object "Testfor tbook" in the constructor ?(Testfor is a class that I wrote.
//////////////////////////////////My code
is:////////////////////////////////// public class BookManager{
private static BookManager instance=new BookManager();
Hashtable hbook=new Hashtable();
public BookManager(){ //<--------------If delete the sentence the compiler report error///////////////////////////////////////////
Testfor tbook;
tbook=new Testfor("345463463","Beginning
Java Programming");
hbook.put(tbook.getIsbn(),tbook);
tbook=new Testfor("10231334","Beginning C# Builder");
hbook.put(tbook.getIsbn(),tbook);
tbook=new Testfor("0120130","Study C++ in 21 days");
hbook.put(tbook.getIsbn(),tbook);
tbook=new Testfor("4643564","Mastering EJB");
hbook.put(tbook.getIsbn(),tbook);
}
public static BookManager getInstance(){
return instance;
}
public Testfor getTestfor(
String isbn){
return (Testfor)hbook.get(isbn);
}
public Testfor[] getBookAsArray(){
return (Testfor[])hbook.values().toArray(new Testfor[0]);
}
public Collection getBookAsCollection(){
return hbook.values();
}
}