java - stop for loop when get a specific value -


i have loop retrives database names .. want when got specific name stop loop , out of it..

tried didn't work :

for (int = 0; < member .length(); i++) {      jsonobject c = member .getjsonobject(i);      // storing each json item in variable     string username = c.getstring(tag_username);     s1=inputname.gettext().tostring();     if (username.equals(s1)){          suc=1;         return null;     }     else {          suc=0;     } } 

also tried break; didn't work either.

how ?

update

this code working fine, found mistake in part of code.

try do ... while loop

int = 0;  {   jsonobject c = member.getjsonobject(i);   string username = c.getstring(tag_username);    i++; } while(!username.equals(inputname.gettext().tostring() && i<member.length()); 

this loop ends, when username equal inputname or when end of list reached.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -