This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
public class Main {
public static void main(String[] args) {
User user = null;
System.out.println(user.name); // Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:3)
}
}
class User {
String name;
}
view raw
gist_java_and_npe.java
hosted with ❤ by
GitHub