It tries to force price to a long primitive to match type 0L . This generates NPE if price null .
This expression works because it avoids implicit type coercion:
n = (n != null) ? new Long( 0L ) : price ;
But, as others said in the comments, what you are doing here seems to make no sense.
source share