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.

SWITCH / IF-ELSE

01955.jpg01956.jpg01957.jpg

i). The IF-ELSE statement is used for manipulating multiple conditions

01958.jpg01959.jpg

whereas SWITCH touches upon only one conditional variable. And different

01960.jpg

values of the variable passes the control to the required case.

01961.jpg01962.jpg01963.jpg(ii). The IF-ELSE statement uses both integer as well as floating type values 01964.jpgwhereas the SWITCH statement only accepts integer values.

 

01965.jpg01966.jpg01967.jpg

(iii). In SWITCH statement all the branches or compound statements are

01968.jpg

executed depending on the value of the same variable on the other hand

01969.jpg

IF-ELSE follows usage of long instruction based statements and may create confusion within blocks.

01970.jpg01971.jpg01972.jpg01973.jpg01974.jpg01975.jpg01976.jpg01977.jpg01978.jpg01979.jpg01980.jpg01981.jpg01982.jpg01983.jpgattention@computerscienceexpertise.com

 

01984.jpg01985.jpg01986.jpg01987.jpg01988.jpg01989.jpg01990.jpg01991.jpg01992.jpg01993.jpg01994.jpg01995.jpg01996.jpg01997.jpg01998.jpg01999.jpg02000.jpg02001.jpg02002.jpg02003.jpg02004.jpg02005.jpg02006.jpg02007.jpg02008.jpg02009.jpg02010.jpg02011.jpg02012.jpg