The document discusses Java control flow statements like if, switch and loops including while, do-while and for loops. It also covers break, continue statements and methods for simple input and output in Java.
The document discusses Java control flow statements like if, switch and loops including while, do-while and for loops. It also covers break, continue statements and methods for simple input and output in Java.
Break and Continue Java supports a break statement that immediately terminate a while or for loop when executed within its body. Java also supports a continue statement that causes the current iteration of a loop body to stop, but with subsequent passes of the loop proceeding as expected.
For-Each Loops Since looping through elements of a collection is such a common construct, Java provides a shorthand notation for such loops, called the for-each loop. The syntax for such a loop is as follows: for (elementType name : container) loopBody
Simple Input There is also a special object, System.in, for performing input from the Java console window. A simple way of reading input with this object is to use it to create a Scanner object, using the expression new Scanner(System.in) Example:
java.util.Scanner Methods The Scanner class reads the input stream and divides it into tokens, which are strings of characters separated by delimiters.