+ 1

explain in detail...how to work try and catch block??

19th Aug 2016, 7:58 PM
raghav mishra
raghav mishra - avatar
5 Respostas
+ 2
Thete is a good explanation in java course. Here is an example: public class MyClass { public static void main(String[ ] args) { try { int a[ ] = new int[2]; System.out.println(a[5]); } catch (Exception e) { System.out.println("An error occurred"); } } }
20th Aug 2016, 9:47 AM
Tiger
Tiger - avatar
+ 2
What do u mean by "exception e"?^
4th Nov 2016, 3:10 PM
gautam p b
gautam p b - avatar
0
try block identifies where exception is occurs and the catch block is used to handle that exception. we put the exception prone statements in try block.
4th Nov 2016, 6:50 AM
Satendra Yadav
Satendra Yadav - avatar
0
"Exception e" is a formal parameter to receive actual parameter. try block throw the object of related exception class we have to receive this object in reference variable of same exception class or of it's parent class.
12th Nov 2016, 3:28 PM
Satendra Yadav
Satendra Yadav - avatar
0
it is not mandatory to write Exception e.. instead you can write exact the type of Exception like Arithmetic Exception and e is a reference.you can put your name also .WITHIN print just print the reference
23rd Nov 2016, 6:38 AM
Somnath Ghosh
Somnath Ghosh - avatar