java - Skipping element in a for loop and reassigning it -


i'm filling parameters in jaspersoft. in report have parameters: parameter_1, parameter_2, parameter_3

int a;  (a = 0; < headers.length; a++) {         parameters.put("parameter_" + a, headers[a]);     } 

i populating parameters in fashion , works. want add new parameter, parameter_groupby determined index (let's want parameter_2 parameter_groupby) did this:

int a;  (a = 0; < headers.length; a++) {         if (a == groupby) {             parameters.put("parameter_groupby", headers[groupby]);             continue;          }         parameters.put("parameter_" + a, headers[a]);     } 

the problem code (assuming groupby value 2) parameter_2 blank want have content of parameter_3

for example

parameter_1= name  parameter_2= date  parameter_3= street 

what second code bit

parameter_1 = name  parameter_2=  parameter_groupby= date  parameter_3= street 

i want group date (parameter_2) want

parameter_1 = name  parameter_2= street  parameter_groupby= date  parameter_3= 

how can achieved? using jdk 1.6 , windows.

it seems me need keep separate index "next parameter put":

int parameterindex = 1; // note: more idiomatic declare iteration variable // inside loop (int headerindex = 0; headerindex < headers.length; headerindex++) {     string header = headers[headerindex];     if (headerindex == groupby) {         parameters.put("parameter_groupby", header);     } else {         parameters.put("parameter_" + parameterindex, header);         parameterindex++;     } } 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -