Java Tutorial/Statement Control/finally
Версия от 17:44, 31 мая 2010; (обсуждение)
Demonstrate finally.
class FinallyDemo {
static void procA() {
try {
System.out.println("inside procA");
throw new RuntimeException("demo");
} finally {
System.out.println("procA"s finally");
}
}
static void procB() {
try {
System.out.println("inside procB");
return;
} finally {
System.out.println("procB"s finally");
}
}
static void procC() {
try {
System.out.println("inside procC");
} finally {
System.out.println("procC"s finally");
}
}
public static void main(String args[]) {
try {
procA();
} catch (Exception e) {
System.out.println("Exception caught");
}
procB();
procC();
}
}