I was researching on ways to tackle NullPointerExceptions and the three things I found to be most useful were :
- Assert statement
- Annotations (@Nonnull, @Nullable)
Using "?." as null check Example : if(MyRef != null){ MyRef.doSomething(); }
The above code can be changed to : MyRef?.doSomething();
Please comment on how helpful these three above mentioned strategies are and if there are any more ways to tackle NullPointerExceptions.