0

How to understand the loops?

Due to the fact that I'm becoming complicated studying the loops.

26th Oct 2022, 2:59 PM
Teddiyaa Noah
Teddiyaa Noah - avatar
2 Answers
+ 3
Maybe the best way is to create your own codes for each loop. Have each one print a number that increases with each loop iteration. See what the difference is.
26th Oct 2022, 3:03 PM
Ausgrindtube
Ausgrindtube - avatar
+ 1
loop is for repeated activity, in real live i.e. if you search for something in a book. What you do: Text whatISearch = "Loops in Java" Page page while( book.hasNextPage() ) { page = book.nextPage() if (page.contains( whatISearch) ) break //stop search // else repeat it in next page } or for( page = book.firstPage(); // start page < book.endPage(); // "stop if not true" page = book.nextPage() ) // "do before repeat" { if (page.contains( whatISearch) ) break //stop search // else: "do before repeat" // check: "stop if not true" condition // repeat }
27th Oct 2022, 4:57 AM
zemiak