Showing posts with label Java Control Statements. Show all posts
Showing posts with label Java Control Statements. Show all posts

Friday, 29 May 2015

Java Control Statements

Control statements are used to change the flow of execution. Java’s control statements can be classified into three categories:

  • Selection Statements (Decision Control Structure)
  • Iteration Statements (Loop Control Structure)
  • Jump statements

Most of the statements have same syntax as the corresponding statements in C/C++. However there are some significant differences:

(i) The conditional expressions used in the if, for, while and do statements must be valid boolean expressions i.e. their values should be either true or false. You cannot use 0 (Zero) instead of false or a non-zero value instead of true that is valid in C/C++.

(ii) Java does not have any goto statement although goto is a reserved word in the language. Java provides labeled break and labeled continue statements, which are often referred to as the civilized form of goto as they are supposed to be better substitutes of goto statement.