Java Learning Made Easy by Dheeraj Mehrotra - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

IF Statement

01795.jpg01796.jpg01797.jpg01798.jpg01799.jpg01800.jpg01801.jpg01802.jpg01803.jpg01804.jpg

This statement acts as a conditional control statement of Java and

01805.jpg01806.jpg01807.jpg

checks the specified condition. If the given condition is true the given

01808.jpg01809.jpg

instruction is executed otherwise the instruction is ignored. There are

01810.jpg01811.jpg

different formats of if statement and is widely used for computation,

01812.jpg01813.jpg

logical reasoning and decision making within a program.

01814.jpg01815.jpg01816.jpgA simple if statement has the following format :

 

01817.jpg01818.jpgif (expression)

 

01819.jpgstatement1;

 

01820.jpg01821.jpg01822.jpg01823.jpgwhere an expression is the condition which if found true executes 01824.jpgstatement1 otherwise the control comes to the next statement. 01825.jpg01826.jpg01827.jpg01828.jpg01829.jpg01830.jpg01831.jpg01832.jpg01833.jpgattention@computerscienceexpertise.com

 

01834.jpg01835.jpg01836.jpg01837.jpg01838.jpg01839.jpg01840.jpg01841.jpg01842.jpg01843.jpg01844.jpg01845.jpg01846.jpg01847.jpg01848.jpg01849.jpg01850.jpg01851.jpg01852.jpg01853.jpg01854.jpg