improving my code

how can i improve my code, is there a better way to store records, also how do i add new records and save the new changes made to existing records any tutorials? any other improvements? thanks in advance.

In general, think about consistent indentation, adherence to the Java naming conventions, use of generics - particularly with collections, and catching specific exceptions and handling them - you should never leave an empty 'catch' block - if you are deliberately not handling an exception, either log a message or put in a comment explaining why. When you use IO classes, e.g. streams, declare your IO class variables before the 'try' block, initialise them inside the 'try' block, and close them in a 'finally' block - handling any exceptions that can be thrown. With wrapped streams, you only need to close the outermost stream wrapper, and it will close the inner ones.

It's generally considered poor practice to declare and initialise multiple objects in a single statement - consider declaring & initialising each separately.

More specifically, you should consider using a TableRowSorter instead of sorting and replacing the table model data. The table model is where the data should be stored - there's no reason to keep a separate list. If you want the data stored in a different form to that provided by DefaultTableModel, provide your own by overriding AbstractTableModel.

Do something with Object 'fr' - if it's used as a Component, declare it as such and initialise it.

as far as how to store records, there are always other ways to do it, but they get more and more complex, and also depend on operations you want to perform on the records. look up data structures. i'd recommend checking out a binary search tree first, then a self-balancing bst before even attempting the more complex structures.

you can also use the 'hashmap' class...

Last edited by emceenugget; 08-14-2009 at 09:47 PM.
Reason: added another note