Inspired by Java Puzzlers conference, spotted interesting behaviour of following code:
public class LongNull { Long longi = null; public long getLongi() { return longi; } public static void main(String[] args) { System.out.println(new LongNull().getLongi()); } }What it produces:
- NullPointerException
- Prints 0
- Prints null
No comments:
Post a Comment