Thanks a lot Phil. I got my code up and running and works fine. I am having a weird error. I put the firstLibrary.printAddress() into System.out.println() and it is printing out null. I was looking at the structure of my Book class for getTitle() and the Book constructor and it is the exact same structure.
My problem is that whenever I run this everything runs fine. Except when I print the avalible books, it prints the exact same book 4 times. I know that it creates an array, because it prints out four times. However, I can't figure out why it prints out the last book added only.
Ok. I am kind of lost. I am not sure how my variable for addBook is wrong. I am creating a new instance of the book class like my method addBook is supposed to do. I tried to remove static on my books varible and I also removed void and it is still giving me the nullPointer exception. How do I change my constructor or variable so that it builds an array?
Thanks, Henry. I fixed my code and it compiled. Excuse me for keeping this thread open, I am pretty new at Java. When I ran it it throws the run time error of : java.lang.NullPointer. at Library.addBook(Library.java:10) ; at Library.main(Library.java:60). I looked online and this exception was caused with an illegal use of null. Like if you try to divide a null variable with a number.
Thanks for replying. Ok, so I tried to insert book into my methods so that: firstLibrary.returnBook(Book("The Lord of the Rings")); . Now it is telling me that the symbol for Book isn't found. I though this was the proper return type?
Hey guys, I am working on a project right now to create a simple library system. I am trying to compile, but I am getting "Incompatible Types; Found : Book; Required java.lang.string" It is on the lines that return b in the available books constructor.
Here is the code I have so far:
Also, my goal with the availableBooks constructor is to get it to where the book doesn't appear on the list of available books when it is borrowed. How could I rearrange my constructor to accomplish this?