Hello, I am doing B&S assignment and trying to implement findByCriteria here to search records in data file. My question is how do I know before have what the length of long is going to be? I have couple of options to do this: 1) Loop through the data file, find matching records and store them in collection and at the end of method convert collection to array and return an array. I looked at arraylist and it stores only Object and has toArray method which converts it to Object, in that case how do I implement this? 2) Loop through the database, store it in an array of boolean (where array length will be num of records in DB), if matching record found store true in array else false, keep count of number of trues encountered. Set long to that length and loop through boolean array to find which ones are true. This probably isnt the good way is it?
Any help on this is appreciated, I tried searching this forum but could not find much discussion on this.
I would opt for choice number one. Store the values in an ArrayList, and use the toArray() method. Then loop through the Object array and fill up a long array.
“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook