Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. public class Program {
  2.  
  3. public static void main(String[] args) {
  4.  
  5. String invalid = "turnip";
  6. int result = -100; // A default result.
  7. try {
  8. // This throws an exception because the string is invalid.
  9. result = Integer.parseInt(invalid);
  10. } catch (NumberFormatException n) {
  11. // ... Do nothing.
  12. }
  13. System.out.println(result); // Prints default result.
  14. }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement