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.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
26 views
Java Primer 2: I/O Methods and Control Flow
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.
Download Complete (Ebook) Oxford Textbook of Epilepsy and Epileptic Seizures by Mark Cook, Samden Lhatoo ISBN 9780199659043, 0199659044 PDF for All Chapters