I am just trying to duplicating it here...
import java.util.List;
import java.util.ArrayList;
public class Unboxing{
public static void main(String[] args){
List<Integer> list = new ArrayList();
list.add(getInteger());
int x = list.get(0);
System.out.printf("x value is %i\n", x);
}
private static Integer getInteger(){
return null;
}
}
And here's the result
$ java Unboxing
Exception in thread "main" java.lang.NullPointerException
at Unboxing.main(Unboxing.java:8)
That's all folks.
No comments:
Post a Comment