Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem On Solving Tricks - Double for loop  RSS feed

 
John A.C
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi guys, lets make this as a piece of challenge.
Reading from file "cache.txt" will result the same Sring[] result.
Tht's for your info

Well, the most challenging part is :
I wanted to sort tht array, in a manner of 5 arrays per row.
Eg :

Row [0] 0193240000,0193240001,0193240002,0193240000,0193240001
Row [1] 0193240002
p/s : this is only for 6 arrays.. if multiple array like it contains of 27 data's it should be looking like
Row [0] 0193240000,0193240001,0193240002,0193240000,0193240001
Row [1] 0193240000,0193240001,0193240002,0193240000,0193240001
Row [2] 0193240000,0193240001,0193240002,0193240000,0193240001
Row [3] 0193240000,0193240001,0193240002,0193240000,0193240001
Row [4] 0193240000,0193240001,0193240002,0193240000,0193240001
Row [5] 0193240000,0193240001

The reson of this is, i need to concatenate each data, rebuild the string into a row / line, so that can be inserted into mysql. For the insert code, i have done tht.

Ah, one more thing,on the 27th array [if referring to the codes above] it'll pops up an error. Wanted to off tht too.

Just the matter now.. now to program the 2 x for loops. Been thinking tht for days :'(.

Please help.
Thanks in advance.

John.
 
Vasu Reddy
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi replace the for loop with this;


for (int y = 0; y < g ; y=y+5) {

int counter = 0;
for (int z = y ; z <g ; z++) {
counter = counter +1;
System.out.println(" : "+y+" : "+result[z]);

if(counter == 5)
break;
}
}
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!