With the Error/output
Sorry for the length.
Or, a much better solution: use a more appropriate data structure. You want a List (either an ArrayList or a LinkedList), which is designed to allow the size to change.
Possibly, but it seems like an awful lot of work to cover up for the fact that you've made a bad decision to start with.
Dustin Schreader wrote:I bet I could do something like this.
My advice: follow Matthew's.
Yes, but it doesn't alter the fact that you're better off with an ArrayList to begin with.
Is there a way that I can convert the arrays I already have to an arraylist?
Sometimes the school of hard knocks is the best way to learn, and the lesson here is:
unless you know how many items you're going to be creating, always use a collection rather than an array.
...there's another big improvement you could make. You're currently using an array of arrays to represent your rows. What I'd suggest is to create a class representing a single row (called Patient - or whatever makes sense in your application). Give that class fields according to what the columns mean. Then you can use an ArrayList<Patient> to hold them in. It will make your code far more readable and maintainable, which is always a good idea.
Dustin Schreader wrote:I guess I don't understand creating a whole new class for just patient information formatting.
Well, something likemight be a start.
However, I suspect that the real problem you're having is that you're spending too much time coding, and not enough thinking about the problem.
You're also not doing yourself any favours with your cryptic codes and field names. What is "pt" for example?
Dustin Schreader wrote:It seems like I'd be sorting through each entire string of combined variables created by my patient class when, let's say I just wanted to compare against the code of the pt to do a search on them not the code, name, physician, floor, and time.
I suspect you need to go through the tutorials for object order and sorting. you should also look at java.lang.Comparable and java.util.Comparator.