~/ learn/ java-from-zero/ cards/ Multi-catch & catch order
1 of 4

Type a multi-catch block for IOException and SQLException

Type a multi-catch block for IOException and SQLException

Answer

try { run(); } catch (IOException | SQLException e) { logger.error(e.getMessage(), e); }

Multi-catch is sugar for two catch blocks with identical bodies. The alternatives must not be subclass-related. e is effectively final.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/bf4a596f-f0da-4a21-bcba-f2e1f61f1721/flashcard utf-8 LF