A RuntimeException typically means something went unexpectedly wrong. Mostly we use it to fail fast on errors that shouldn’t occur during normal operation, or that we aren’t prepared to handle gracefully.
Running this program will cause it to throw an exception, print an error message and stack trace, and exit with a non-zero status.
When the first RuntimeException in main is thrown, the program exits without reaching the rest of the code. If you’d like to see the program try to create a temp file, comment out the first exception and uncomment the file creation code.
Note that unlike some languages which use exceptions for handling of many errors, in Java it is common to use both checked exceptions and return values for error handling, depending on the situation.