Java Statements
This page contains a table of Java statements. The contents of the table have been take from the 4th edition of "Java in a Nutshell", by David Flanagan, published by O'Reilly.
Statement Purpose Syntax ---------------------------------------------------------------------- expression side effects var = expr; expr++; method(); new Type(); ---------------------------------------------------------------------- compound group statements {statements} ---------------------------------------------------------------------- empty do nothing ; ---------------------------------------------------------------------- labeled name a statement label: statement ---------------------------------------------------------------------- variable declare a variable [final] type name [= value] [, name [= value]] ...; ---------------------------------------------------------------------- if conditional if (expr) statement [else statement] ---------------------------------------------------------------------- switch conditional switch (expr) { [case expr: statements] ... [default: statements] } ---------------------------------------------------------------------- while loop while (expr) statement ---------------------------------------------------------------------- do loop do statement while (expr); ---------------------------------------------------------------------- for simplified loop for (init; test; increment) statement ---------------------------------------------------------------------- break exit block break [label]; ---------------------------------------------------------------------- continue restart loop continue [label]; ---------------------------------------------------------------------- return end method return [expr]; ---------------------------------------------------------------------- synchronized critical section synchronized (expr) {statements} ---------------------------------------------------------------------- throw throw exception throw expr; ---------------------------------------------------------------------- try handle exception try { statements } [catch (type name) {statements}] ... [finally {statements}] ---------------------------------------------------------------------- assert verify invariant assert invariant [:error]; ----------------------------------------------------------------------