• Post Reply Bookmark Topic Watch Topic
  • New Topic

How can I get my showAll() and my insert and fetch method to actually print out student records?  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I get my showAll() method to print out all student records because as it stands it only print out one student record and the rest of the records are printed as null which is not what I want. Also, how can I get my fetch method to actually print a student record based on just the string parameter I input into that method. Here is my code so far.





 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Formatting things, I am afraid:-
Don't copy line numbers into the code tags; as you see, they have spoiled the formatting. Don't double‑space code and don't write anything after a {. Except for something like this:-always push the enter key after a {
Don't write field names starting with CapitalLetters except for constants; I think this is a better way to write that constructor:-The this. part is essential: that tells the javac tool to use the field of that name rather than the parameter/local variable. Obviously you need to change the field names. You sometimes have to take copies of variables in constructors, but there is no need for that sort of thing for immutable classes (String) or primitives (int and double).

I can't seem to find a showAll() method. How are you going to write it? Are you going to iterate the array from one end to another and print the details of each listing object? If all the records are printed as null, that means you haven't added them to the array properly. Remember your 100‑element array starts off life containing one hundred nulls and you need to replace those nulls with something else. You can try a test with == null to miss it out of the printout, but that won't solve your actual problem. Please explain the algorithm you are using to fill the array. It looks like a data structure I'm not familiar with.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!