This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Switch statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Switch statement" Watch "Switch statement" New topic
Author

Switch statement

Charlie Swanson
Ranch Hand

Joined: Jan 29, 2001
Posts: 213
Hello, I was reviewing for the exam, and I was wondering if
anyone could be of assistance in explaining the below statement.
An example would probably help. By the way what is a nested case
label and what do the notes mean when they say don't clash with outer case labels.
The switch can be nested. Nested case labels are independent, don�t clash with outer case labels.
Thank you for the help in advance.
venkat_alladi
Greenhorn

Joined: Jan 31, 2001
Posts: 12
It means the following
int c;
switch(c){
case 0: Do something;
case 1:case 2:
switch (c){
case 0: Do something;
case 1: Do something;
}
}
The above switch is nested and inside switch arguement is the same as the one outside and they are independent.
Hope this helps.


------------------
Val Dra
Ranch Hand

Joined: Jan 26, 2001
Posts: 439
it means you can have same case labels in nested switch statement. Example
int i = 1;


Val SCJP <BR>going for SCJD
Charlie Swanson
Ranch Hand

Joined: Jan 29, 2001
Posts: 213
Thanks, that clears it up.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Switch statement
 
Similar Threads
Clash of Civilizations!!