With assertions enabled the above code prints 210210Exception in thread "main" java.lang.AssertionError at asert2.m1(asert2.java:12) at asert2.main(asert2.java:19) My doubt is shouldn't it print 210210-1 followed by assertion error? Thanks Veena
SCJP1.4
"Continuous effort - not strength or intelligence - is the key to unlocking our potential."
*Winston Churchill
With assertions enabled the above code prints 210210Exception in thread "main" java.lang.AssertionError at asert2.m1(asert2.java:12) at asert2.main(asert2.java:19) My doubt is shouldn't it print 210210-1 followed by assertion error? Thanks Veena
I think the answer is correct. Since when Assert is false, the EXIT method will be called. So the -1 won't be printed. Am I right? Shirley
Originally posted by Veena Point: Even I thought like that.But then again if that is the case why is it printing 01 in between....? Thanks Veena
You mean the 0 1 in the printing string. I think that's because it is in the switch block, when j=0 or j=1, it goes to the case "0" or "1" and doesn't execute the sentences in the case default, so assert won't be executed. Am I right? Shirley