TL;DR
- Le Problème: Mécanique technique du problème CTCI 13.2.
- L'Approche: CTCI problem 13.2: how return statements in try, catch, and finally blocks interact in Java runtime execution.
- Complexité: Empreinte mémoire et temps optimaux.
Cet article explique clairement le problème CTCI 13.2.
1. Contexte et Énoncé
CTCI problem 13.2: how return statements in try, catch, and finally blocks interact in Java runtime execution.
2. Code et Implémentation
public static int testFinally() {
try {
return 1;
} finally {
return 2; // Finally block overrides try return, returns 2!
}
}
3. Résumé et Cas Limites
Toujours vérifier les conditions aux limites et les valeurs nulles.
