Skip to content

Instantly share code, notes, and snippets.

@flaviocdc
Created November 10, 2014 20:00
Show Gist options
  • Save flaviocdc/a76a580a59ed67da74c8 to your computer and use it in GitHub Desktop.
Save flaviocdc/a76a580a59ed67da74c8 to your computer and use it in GitHub Desktop.
Finally Example
public class FinallyExample {
public static void main(String[] args) {
System.out.println(foo("1"));
System.out.println(foo("a"));
}
public static int foo(String numStr) {
try {
int x = Integer.parseInt(numStr);
return x;
} catch (Exception e) {
return -1;
} finally {
return Integer.MIN_VALUE;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment