This piece of code works fine :-
if (1 <= 3) {
Integer secondNull = nullInt;
} else {
Integer secondNull = -1;
}
System.out.println("done");
But this throws null-pointer exception, while Eclipse warning that there is need for auto-unboxing :-
Integer nullInt = null;
Integer secondNull = 1 <= 3 ? nullInt : -1;
System.out.println("done");
Why is that so, can somebody guide please?
Aucun commentaire:
Enregistrer un commentaire