0

When should I use a new block of try statement?

Because I am a little bit confusing...

16th Oct 2020, 6:58 AM
OmerA
OmerA - avatar
2 Respuestas
+ 1
When you think that there is something in the program, it may give the exception, for example, that the user enters a value of the integer type and is required to enter a value of the type String. So you do a try block to avoid the error and the program keeps running, meaning it does not stop.
16th Oct 2020, 7:11 AM
Lama Alathwary
+ 2
If your program has possibility to contain more than one exceptions. Than you have to Cath multiple exceptions. If don't want do this, than Catch all the exceptions. I.e .1 try{ }catch(IOException e){ //Catches single exception } I.e.2 //Catches both exception try{ }catch(IOException e){ }catch(NullpointerExeption e){ } I.e.3 try{ }catch(Exception e){ //Catches all the exception }
16th Oct 2020, 7:21 AM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar