I've a situation where i am plotting graph using Aspose library. I created a graph but i hardcoded everything like arrays and column names when filling those arrays. I've given a task to make that process dynamic and read everything from database. I have total record size stored in count variable, which helped me to initialize array of that size. I also have information about number of arrays to be created stored as columnCount. With this information count and columnCount, how can i create arrays since i'll not be hardcoding them now. It will be created inside this block.
for(int i=0; i<columnCount; i++){
//double type array will be initialized here. each of size count.
}
public static void main(String[] args){
ResultSet rs = ReportHandler.getQueryResult();
rs.last();
// get total number of records for array size.
int count = rs.getRow();
// this count will tell number of arrays to be created.
int columnCount = ReportHandler.getCount("035","005");
// this was static code. now i need to make it dynamic.
double[] policyYear = new double[count];
double[] commPremium = new double[count];
for(int i=0; i<columnCount; i++){
//double type array will be initialized here. each of size count.
}
rs.beforeFirst();
int j=0;
// now i've a result set
while(rs.next()){
//static code, need to make it dynamic,
policyYear[j] = rs.getDouble("policy_year");
commPremium[j] = rs.getDouble("commulative_premium");
j++;
}
}
while(rs.next()){inside the for loop. I guess you want the call tonext()in theForUpdate, i.e.j++, rs.next().policyYear,commPremiumetc ? In the below answer you mentioned that you know the size, so you can Array or List. But I think your question is different.You need to rephrase your question and explain clearly what you mean by 'make it dynamic' ?policyYear,commPremarrays is just an example. Next time may be i need more than or less than two arrays for my process. Let me rephrase my question.