• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

java code problem  RSS feed

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi!
1-I try to put 5 diffent books in my library object but toString() method dose not work if I write like this: bok[].gettitle() but what do I put in the bok array (bok[?]).
2- How do I test the program?
 
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Your toString method should loop through all the books it has to get the information about book[0] through to the end.

2. What would you like to test? Your code has problems such as that Book[] never being initialised but essentially that main method at the end is creating a library and adding 5 books, to test further you can add the method getBook(int index OR String isbn etc).
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem you got is that you need to loop through your array of books.

Also why are you using arrays for such a thing as this, wouldnt it be better to have a dynamic list like an ArrayList? This would mean you would not have to specifiy a size you could jsut add as many books as you like.

O btw dont really think this is an Intermediate question?

John
 
Anything worth doing well is worth doing poorly first. Just look at this tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!