Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

for loop

 
tim hunt
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 7575
52
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim, It would be a lot easier to answer your question if you gave us some code to look at.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic