Java Static Initializer Block

  • + 2 comments

    But why use try-catch?

    • + 0 comments

      I don't think you have to. I just did it this way since they insinutated at it with "java.lang.exception" in their desired string.

    • + 0 comments

      You can simply print out the error message using System.out.println("errorMessage");,

      But for better learning try-catch is good practice.