Chapter 4. Statements and Comments

  • Organizing Statements

  • Expression Statements

  • Selection Statements

  • Looping Statements

  • Transfer of Control Statements

  • Comments

  • Javadoc

  • Exercises

  • Some Light Relief—MiniScribe: The Hard Luck Hard Disk

Huh? What is it, Lassie? What is it, girl?

You say someone has left the braces off their if statement, and that it's likely to be a maintenance problem? Good girl, Lassie!

Statements are the way we get things done in a program. Here are the most common statements in Java.

Organizing statements

{ /*statements*/ }

and

emptyStatement ;

Expression statement

someExpression ;

Selection statements

ifswitch

Looping statements

forwhile

Transfer of control

return

Get Just Java™ 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.