Java 14 new features | Helpful Null Pointer Exception in java JDK 14 | Java Beam

Publié le: 26 septembre 2020
sur la chaîne: Java Beam
584
5

Java 14 New Features | Helpful Null Pointer Exception in java JDK 14| Java Beam


Null Pointer Exceptions are a nightmare for any java developer. Before java 14, it was tricky to debug the infamous NPEs(Null Pointer Exception).
Developers had to fall onto other debugging tools or manually figure the variable/method that was null since the stack trace would only show the line number.
Before Java 14:
String name = a.getBlog().getAuthor()
//Stacktrace
Exception in thread "main" java.lang.NullPointerException at NullPointerExample.main(NullPointerExample.java:5)
Java 14 introduced a new JVM feature, which gives better insights with a more descriptive stack as shown below:
Exception in thread "main"
java.lang.NullPointerException: Cannot invoke "Blog.getAuthor()" because the return value of "Article.getBlog()" is null at NullPointerExample.main(NullPointerExample.java:4)
Note: The above feature is not a language feature. It’s an enhancement in the runtime environment.
#JavaBeam #Java14NewFeatures #HelpfulNPEInJava14 #Java


Sur cette page du site, vous pouvez voir la vidéo en ligne Java 14 new features | Helpful Null Pointer Exception in java JDK 14 | Java Beam durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Java Beam 26 septembre 2020, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 584 fois et il a aimé 5 téléspectateurs. Bon visionnage!