Null pointer exception

https://ide.codingblocks.com/s/151850 This code is showing null pointer exception in the last line

Heyy @tanjuljain19,
I have made small changes from line 223. Kindly compare the codes and understand your mistakes. They were very silly errors and should be avoided in the future. https://ide.codingblocks.com/s/152309

Will writing (temp1!=temp2) wouldn’t compare addresses.I thought of comparing the addresses because the data may be repeated. Sir, plz point out if it wrong to write(temp1!=temp2)

Hi @tanjuljain19,
The approach you undertook had some flaws. First our answer should be -1 if linked lists are not matching. Then since the linked lists are different. The address of the same valued node will be different, if it exists.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.