Regulations for Using Exceptions inside Java the actual hook (NullPointerException e) System.out.println("refVar is null!"); This is pure overkill. You can instead use the much simpler if statement to handle these types of simple errors. if (refVar!=null) System.out.println(refVar.toString(); different System. out. println("refVar is definitely null"); If your computer code can perform a very simple logic test, as displayed here, to manage an error, do so, instead as compared to using an exception to this rule subject to handle the miscalculation. If python catch nor throw exceptions When anyone call any method the fact that throws a good checked exclusion, you must possibly throw the exemption or get it. If you choose that you can't handle this different in the approach where that occurs, compose a toss statement to be able to deliver the exception upwards to the calling approach, which must then both handle it with a good exclusion handler, or throw this up to it has the calling process. The right away set of examples present how you must sometimes get or throw a new looked at exception, in buy to avoid compiler errors. The first example demonstrates signal that throws the IOException. The statement inside the process getFileLength may possibly throw a great IO exemption when it cell phone calls the constructor of the RandomAccessFile class. In addition, typically the statement that calls this period method of typically the RandomAccessFile object may likewise throw an IOException. An individual thus specify the particular punches offer in the assertion for the getFileLength process to pitfall IOException.