课程: Java Exception Handling

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Runtime exception: Handling of NullPointerException

Runtime exception: Handling of NullPointerException - Java教程

课程: Java Exception Handling

Runtime exception: Handling of NullPointerException

- [Presenter] We have reviewed examples of the runtime exceptions including the number format exception and the arithmetic exception. Now, for the most popular of them all, the Null Pointer Exception or NPE. In this video, we will learn exactly what not to do with them as well as how to resolve NPEs. As the reminder, the null pointer exception is caused whenever your code attempts to use an object that is null or has not yet been instantiated. For example, here on line 109, let's say I made a mistake and forgot to instantiate the sequence list variable to an empty list. Note that my IDE actually gives me a warning on line 110. We can see the warning by clicking on the light bulb here as well as some exception handling options? And we can also see the warning in the bottom left hand corner of my IDE. Remember that NPEs are still runtime exceptions. So our JVM or compiler will allow our application to run and continue. It…

内容