This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Hi! I have a problem with the following: Calling delete(record) seems to delete a record but does not update the record count. The db.db provided with my assingment contains 24 records. When I delete a record the record counter keeps the same (24) but only 23 records are available. Iterating over the 24 records throws a NullPointerException reading record(1) which I have deleted. In this case record number 1 does not exist any longer. What happens if I delete the first 12 records and append 12 records. Record number 1-12 does not exist but 13-36. The record count is 24 but I can't loop 1 to 24. Do we have to deal with this? This problem occurs to my client refreshing the table after deleting a record. Kind regards Jochen
Jochen - I can't be 100% sure without looking at the code, but I think if you delete a record it is marked as inactive by setting the first byte to 1. readRecord returns null if you read that inactive (deleted) record. I don't think readRecord is throwing a NullPointerException, I think it may be your code that is. If a method can return null, then you need to handle that when calling that method. I never called delete in my application. Do your requirements specify that the user needs to delete records? -BJ