Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** A for loop is like a while loop. */
- for(...) {
- // execute until condition is false
- }
- /** Except for loop declarations consists of 3 parts. */
- for(declaration; condition; post-execution) {
- // execute until condition is false
- }
- /** This is because for loops maintain their own variable. */
- for(int i = 0; i < 10; ...) {
- }
- /**
- The last section is used to execute code which helps reach the condition.
- In this case, we want 0 to increase.
- */
- for(int i = 0; i < 10; i++) {
- }
- /** This is handy for "looping over arrays" to set values. */
- int[] numbers = new int[5];
- for(int i = 0; i < numbers.length; i++) {
- numbers[i] = 10;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement