fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. static int input;
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. // your code goes here
  14. //System.out.println("Enter an integer number: ");
  15.  
  16. try {
  17. //input = "YMT";
  18. //System.out.println("You've entered number: " + input);
  19. String s = "irshad";
  20. int i = Integer.parseInt(s);
  21. // this line of code will never be reached
  22. System.out.println("int value = " + i);
  23. } catch (NumberFormatException e) {
  24. System.out.println("You've entered non-integer number");
  25. System.out.println("This caused " + e);
  26. }
  27.  
  28. int a,b,c;
  29. try
  30. {
  31. a=0;
  32. b=10;
  33. System.out.println(" a = " + a + " b = " + b);
  34. System.out.println(" Division - a / b : ");
  35. c=b/a;
  36. System.out.println("This line will not be executed");
  37. }
  38. {
  39. System.out.println("Divided by zero" + e);
  40. }
  41. }
  42. }
  43.  
Success #stdin #stdout 0.1s 320512KB
stdin
Standard input is empty
stdout
You've entered non-integer number
This caused java.lang.NumberFormatException: For input string: "irshad"
 a = 0 b = 10
 Division - a / b : 
Divided by zerojava.lang.ArithmeticException: / by zero