Even after odd (please tell me what is error in it)

while(temp.next!=null)

u missing the last node value
correction:
while(temp!=null)