package com.codemonkey;
import static java.lang.System.out;
import static java.lang.System.err;
public class Main{
public static void main(String[] args){
try{
Main.metodoInterrumpido();
out.println("A");
}finally{
out.println("B");
}
out.println("C");
}
static void metodoInterrumpido() throws InterruptedException{
throw new InterruptedException("El tiempo ha terminado.");
}
}
*/
//Salida:
//Error de compilación
//se necesita poner throws InterruptedException en el metodo main
1 Response
import static java.lang.System.err;
public class Main{
public static void main(String[] args){
try{
Main.metodoInterrumpido();
out.println("A");
}
catch(Exception e){
e.printStackTrace();
}finally{
out.println("B");
}
out.println("C");
}
static void metodoInterrumpido() throws InterruptedException{
throw new InterruptedException("El tiempo ha terminado.");
}
}
Write a comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.