Hi all,
I have a question about how to build my return array from my business layer search method. This method has the following basic structure:
1. Find all records that match the criteria (Using the Data class method and
so this returns an array of record numbers)
2. Read each of these records and check to see that they match the criteria exactly. If they do then add this contractor's details (as a
string array) to an arrayList.
3. Convert this arrayList of string arrays to an array of string arrays (String [][]).
4. Return this string array.
My problem is that I am sure that there is an easy way to build the string [][] from the ArrayList of String []'s.
I thought I could do the following but it seems to throw a ClassCastException.
ArrayList matchingContractors;
String [][] returnArray;
.
.
// If a matching contractor then add the string details to the arraylist
matchingContractors.add(contractor.getDetailsAsStringArray);
.
.
// Convert ArrayList of matchingContractors to string array
returnArray = (String [][]) matchingContractors.toArray();
return returnArray;
Can anybody help me out?