Why do i need to throw exception here | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why do i need to throw exception here

In the code when i remove throws Exception it won't compile. Plis tell me the specific reason. I mean which line requires the exception to be thrown. Thank you https://code.sololearn.com/c7xj5SK1w4CW/?ref=app

29th Oct 2020, 6:29 PM
stephen haokip
stephen haokip - avatar
1 Answer
+ 4
BufferedReader.readLine() throws an IOException You need to wrap these calls in a try catch to handle them or throw the exception up the call stack. https://docs.oracle.com/javase/8/docs/api/java/io/BufferedReader.html
29th Oct 2020, 7:24 PM
ChaoticDawg
ChaoticDawg - avatar