Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: switch Statement - Overview

Purpose of switch: select one of many possible statements to execute

Tutorial Details:

The if statement allows you to select one of two sections of code to execute based on a boolean value (only two possible values). The switch statement allows you to choose from many statements based on an integer (including char) or enum value.

switch
The switch keyword is followed by a parenthesized integer expression, which is followed by the cases, all enclosed in braces.. The switch statement executes the case corresponding to the value of the expression. Normally the code in a case clause ends with a break statement, which exits the switch statement and continues with the statement following the switch. If there is no corresponding case value, the default clause is executed. If no case matched and there is no default clause, execution continues after the end of the switch statement.
case
The case keyword is followed by an integer constant and a colon. This begins the statements that are executed when the switch expression has that case value.


 

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

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
switch Statement - Overview

View Tutorial:
switch Statement - Overview

Related Tutorials:

Java Tip 68: Learn how to implement the Command pattern in Java - JavaWorld - February 1999
Java Tip 68: Learn how to implement the Command pattern in Java - JavaWorld - February 1999
 
J2SE 1.4 premieres Java's assertion capabilities, Part 1
J2SE 1.4 premieres Java's assertion capabilities, Part 1
 
Implement Design by Contract for Java using dynamic proxies
Implement Design by Contract for Java using dynamic proxies
 
Reinvented wheel
Reinvented wheel
 
Create your own type 3 JDBC driver, Part 3
Create your own type 3 JDBC driver, Part 3
 
How to build an interpreter in Java, Part 1: The BASICs (JavaWorld / May 1997 / by Chuck McManis)
How to build an interpreter in Java, Part 1: The BASICs (JavaWorld / May 1997 / by Chuck McManis)
 
Build an interpreter in Java -- Implement the execution engine (JavaWorld / July 1997 / by Chuck McManis)
Build an interpreter in Java -- Implement the execution engine (JavaWorld / July 1997 / by Chuck McManis)
 
Make a statement with javac!
Make a statement with javac!
 
Unwrap the package statement's potential
Unwrap the package statement's potential
 
High-availability mobile applications
High-availability mobile applications
 
SQL Database Access with DBTags
SQL Database Access with DBTags In a J2SE or J2EE application, Java Database Connectivity (JDBC) can be used to create a connection with a SQL database, create database tables, retrieve result sets, and update the database. To use a database from a Jav
 
Wakeonlan
What is wakeonlan? wakeonlan is a small OS independent java program that sends 'magic packets' to wake-on-lan enabled ethernet adapters and motherboards in order to switch on the called machine.It runs on every machine with an installed 1.4 java runtime.
 
JSyntaxColor 1.2.7
JSyntaxColor 1.2.7 JSyntaxColor is a library for coloring in real time user text input.
 
SOAP Compression Sender for Apache Axis
Axis can be extended with this transport sender to support the compression of SOAP messages. The sizes of SOAP messages are dramatically reduced resulting in faster transmission over slow network connections. The extension is easy to install and can be us
 
Develop aspect-oriented Java applications with Eclipse and AJDT
AspectJ is an aspect-oriented extension of the Javaâ„¢ language that enables a modular implementation of crosscutting concerns. This crosscutting behavior, which can be static or dynamic, presents an extra challenge to tools that support AspectJ. The AJDT
 
Networking our whiteboard with servlets.
Find out how to easily replace the RMI and sockets networking layers with servlets.
 
Migrating from Windows to Linux, Part 1: Preparation
Want to switch to Linux, but don't know where to begin? In Part I of Migrating from Windows to Linux, THG will help you prepare for the big move. Step-by-step instructions and printable checklists will ensure your happy and safe journey into Linux.
 
What is the correct form of a MIDlet suite version number?
One character can be the difference between a successful installation and a failed attempt. Check your knowledge of MIDlet versioning.
 
SSH Port Forwarding Through a Proxy Server (Community-Submitted Tech Tip)
Learn how to use SSH port forwarding (tunneling) through a proxy server for secure connections.
 
Sun StorEdge 3511 SATA Array With 400 GB Configurations
An additional 12 configurations are now available with the Sun StorEdge 3511 SATA Array. With these new 400 GB configurations, users have access to massive density with configurations that support up to 2.4 TB per rack unit. A full rack of these arrays ca
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.