Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners What is the difference between an if statement and a switch statement?
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Java Coder
What is the difference between an if statement and a switch statement?
1 Answer(s)      a year and 7 months ago
Posted in : Java Beginners


Hi,

What is the difference between an if statement and a switch statement?

Thanks,


Advertisement
View Answers

April 17, 2013 at 11:49 AM


Hi,

The if statement gives options to select one option from two choice of code to execute based on boolean value (only two possible values). Whereas the Switch statement offers you multiple choice of option from many statement based on an integer (including char) or enum value.

Go through this article links for get clear idea about if statement and switch statement in Java program.

http://www.roseindia.net/java/java-tips/flow/switch/switch-general.shtml

http://www.roseindia.net/java/jdk7/IfStatement.shtml

http://www.roseindia.net/java/jdk7/SwitchStatemnet.shtml

Thanks,



Related Tutorials/Questions & Answers:
Advertisements
Advertisements
 

 

 

DMCA.com