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

Ads
 

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

Hi,

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

Thanks,

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,

Ads









Related Tutorials/Questions & Answers:
What is the difference between an if statement and a switch statement?
What is the difference between a break statement and a continue statement?
Advertisements
difference between prepared statement and statement
What is the difference between the >> and >>> operators?
what is the difference between extends and implements
what is the difference between extends and implements
what is the Difference between weblogic and jboss?
what is the difference between pop and oop
What is the difference between hibernate and spring
What is the difference between $message and $$message?
What is the difference between a constructor and a method?
What is the difference between a JDK and a JVM?
What is difference between Path and Classpath?
What is the difference between JPA and Hibernate?
what is the difference between distributed application and web application?
What’s the difference between load() and get()?
What is difference between singleton and prototype bean?
What is the difference between JSF, Servlet and JSP?
what is the difference between productList==null and productList.size()==0
What is the difference between the Boolean & operator and the && operator?
What are difference between Bean Factory and Application Context ?
What is the difference between component and tag in JSF?
What is the difference between GET and POST method?
What is difference between UNIX Hosting and Window Hosting?
What is the difference between a data analyst and a data scientist?
What is difference between data analyst and data scientist?
What is the difference between Big Data and Hadoop?
What is the difference between Big Data and Hadoop?
what is the difference between access specifiers and access modifiers in java?
In Java, what's the difference between public, default, protected, and private?
What is the difference between a static and a non-static inner class?

Ads