Trycatch | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

Trycatch

A complition error is not showing when writing print statement after catch block. And showing when written after finally block. This all is happening inside a for loop with a break statement in a try block..? Pls help

17th Sep 2020, 6:47 AM
Nid
4 Antworten
+ 4
Will you please show your code?
17th Sep 2020, 6:59 AM
The future is now thanks to science
The future is now thanks to science - avatar
0
Psvm(){ for(int i =0 ; i less than 4 ; i++) { try{ break; } finally{ sysoln(" finally"); } Sysoln("end");. ------- here is it showing CTE } }
17th Sep 2020, 7:04 AM
Nid
0
Nid when you say 'break' the loop is terminated. So as soon as the control reaches the try block, it executes break so the last print statement will never execute. It is an unreachable statement.
17th Sep 2020, 7:17 AM
Avinesh
Avinesh - avatar
0
Psvm(){ for(int i =0 ; i less than 4 ; i++) { try{ break; } Catch(Exception e){ sysoln(" exep"); } Sysoln("end");. ------- this is not executing but also not showing error as in the above case } } Executing After catch block
17th Sep 2020, 7:21 AM
Nid