i think it's the j=i line that would throw the exception. since j is an int, it only holds a value, not an object. so, when you try to assign i to j, you are basically doing this:
j = i.intValue();
but since i is null, you get your NPE.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Joined: Jan 14, 2009
thanks sagar you helped me to find out mine mistake.....
thanks campbell you have given me a great source of information......
thanks fred you have pointed very correctly....I checked by changing both the instance variable type to "Integer"
and "int" as well......now it is not giving any run time exception.....instead of that its giving as expected "null" and "0" as output...
once again thanks a lot to all of you guys........
k is never assigned a value so it remains null.
i only gets one assignment, but it's with the value of k which is null.
The assignment to j tries to auto-unbox i, but that's still null. That's why you're getting an NPE.