Hi,
What is the difference between an if statement and a switch statement?
Thanks,
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,
Ads