Search

Friday, December 14, 2018

Nested Switch Statements

It is possible to have as witch as part of the statement sequence of an outer switch. This is called a nested switch. Even if the case constants of the inner and outer switch contain common values, no conflicts will arise.
For example,
the following code fragment is perfectly acceptable.
switch(ch1) 

case 'A': 
System.out.println("This A is part of outer switch.");
 switch(ch2)
 {
 case 'A':
 System.out.println("This A is part of inner switch");
 break; case 'B':
 //
 ... } 
// end of inner switch break; case 'B': // ...


0 comments:

Post a Comment