posted 19 years ago
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.
Thanks in advance.