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': // ...
Friday, December 14, 2018
Nested Switch Statements
December 14, 2018
No comments
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment