- 2

java

Drag and drop from the options below to create a method that throws an IOException if the parameter is negative. public void do(int x) { if(x<0) { IOException(); } } throws IOException try new catch throw

13th Apr 2020, 5:32 PM
Shlok Dayma
Shlok Dayma - avatar
2 Réponses
+ 1
It is a quiz question from the course. public void do(int x) throws IOException { if(x<0) { throw new IOException(); } }
13th Apr 2020, 9:39 PM
Avinesh
Avinesh - avatar
0
IllegalArgumentException is beter here
13th Apr 2020, 6:40 PM
zemiak