Java Statement

// By:Team // No Comment

Email this to someonePrint this pageShare on Google+2Share on Facebook2Tweet about this on TwitterShare on LinkedIn1Share on Reddit0Pin on Pinterest0Share on StumbleUpon3


Types of Java Statement

  • Control Statement
  • Assignment Statement
  • In this chapter we will discuss about control statements. Visit here for assignment statement topic.

 

Control Statements

  • Conditional execution
  • Looping
  • Flow Control Statement

 

Types of Conditional Execution

  • If Statement
  • If – Else statement
  • If- Else-if statement
  • Switch Statement

 

If Statement
If statement in java encloses some code which is executed only if a condition is true. If statement only takes a boolean expression as its condition.

Note*: Unlike other languages Java does not accept numbers as conditional operators. It only considers boolean expressions as conditions which returns TRUE / FALSE.

Syntax of If Statement

If Else Statement
If Else statement consists of one if condition and and one else part. It encloses some code which is executed only if the if condition is true, if its false then the else part of the code will be executed. If else statement takes boolean expression as its condition.

Note*: Unlike other languages, Java does not accept numbers as conditional operators. It only considers boolean expressions as conditions which returns TRUE / FALSE.
E.g if(1==1) is accepted as it is boolean expression and will return true. if(x=1) statement is not allowed in java.

Syntax of If Else Statement

If Else If Statement
If Else If statement consists of multiple if conditions and and an else part. If the if condition is true then the enclosed code will be executed. But if the if condition is false then it will check for the next if condition. If the next if condition is true then the enclosed code will be executed otherwise the else part of the code will be executed. If Else If statements takes boolean expression as its condition .

Note*: Unlike other language Java doesn’t accept numbers as conditional Operator. Only thing that can be accepted as condition is boolean expression which returns TRUE / FALSE.
E.g If(x=1) is not allowed while if(1==1) is accepted as it is boolean expression and will return true.

Syntax of If Else If Statement

Types of Looping Statement

  • For Loop
  • While Loop
  • Do – While Loop

 

Types of Flow Control Statement

  • Return Statement
  • Continue Statement
  • Break Statement

Email this to someonePrint this pageShare on Google+2Share on Facebook2Tweet about this on TwitterShare on LinkedIn1Share on Reddit0Pin on Pinterest0Share on StumbleUpon3

About Team

Browse Archived Articles by Team

Related

Sorry. There are no related articles at this time.