public class ThrowException {
public static void main(String[] args) {
try {
foo();
}
catch(Exception e) {
if (e instanceof IOException) {
System.out.println("Completed!");
}
}
}
static void foo() {
// what should I write here to get an exception?
}
}
Hi! I just started learning exceptions and need to catch an expetion, so please can anybody provide me with a solution?
I'd be very grateful.
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…