This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes for loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "for loop" Watch "for loop" New topic

for loop

tim hunt

Joined: Apr 19, 2001
Posts: 9
Hi all,
Here I go. I'm running a method which uses a for loop to run through a StringBuffer until a criteria is matched. The loop then continues until the criteria is matched again. At this point the data is manipulated. Now when my method is called again the loop starts from zero again, ie endless loop. Is there anyway I can get the loop to start where it finished once the method is called again.
Thanks guys and girls
Junilu Lacar

Joined: Feb 26, 2001
Posts: 6521

Tim, It would be a lot easier to answer your question if you gave us some code to look at.

Junilu - [How to Ask Questions] [How to Answer Questions]
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
In your for loop initialization where you normally say "int i=0;"
instead you say
int x = 0;
for (int i = x; etc)
then you control the value of the x so that the next time is starts at something other than 0.

"JavaRanch, where the deer and the Certified play" - David O'Meara
subject: for loop
It's not a secret anymore!