Do use assertions, even in public methods, to check for cases that you know are never, ever supposed to happen

Do use assertions, even in public methods, to check for cases that you know are never, ever supposed to happen

this is an include codes blocks that should be never reached including the default of a switch statement as follows:

switch(x) {
case 2: y = 3;
case 3: y = 17;
case 4: y = 27;
default: assert false; // We\'re never supposed to get here!
}

By:UMANG
Date:2002-03-09 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related scjp1.5 chap4 Links

scjp1.5 chap4 interview questions and answers for experienced and fresher