sling - Java do while loop to for each or for loop -
i'm pretty new java , trying figure out how convert below code loop or each loop.
do { testpages.push(testparentpage); if(homepage != null && testparentpage.getpath().equals(homepage.getpath())){ isparent = true; break; } } while((testparentpage = testparentpage.getparent()) != null);
any appreciated! thanks!
it can rewritten in loop this:
for (; testparentpage != null; testparentpage = testparentpage.getparent()) { testpages.push(testparentpage); if(homepage != null && testparentpage.getpath().equals(homepage.getpath())){ isparent = true; break; } }
thought must admit don't know if serves benefit.
Comments
Post a Comment