mdixon18
mdixon18

Reputation: 1219

Putting a while loop into a for loop

Is there anyway to simply TURN this into a for loop?

while ((something == false) && (s < string.length-1)){ }

Upvotes: 0

Views: 81

Answers (2)

Phineas
Phineas

Reputation: 103

for(int i=false;i<string.length-1;i++)

I am thinking that this will work

Upvotes: 0

samuraiseoul
samuraiseoul

Reputation: 2967

for( <x> ; (something == false) && (s < string.length-1) ; <y> ){
 //do whatever
}

put into x whatever you need to declare and into y whatever should increment everyloop, if anything. You can have nothing in there too.

Upvotes: 2

Related Questions