Java : Merging two sorted linked lists
===

I have developed a code to merge two already sorted linked lists in java.

I need your expert guidance for the following.
1.How do I retain the value of head node of merged list without using tempNode?
=
2.Can this code be better optimized?
=

Thanks


public static ListNode mergeSortedListIteration(ListNode nodeA, ListNode nodeB)

	{
		ListNode mergedNode ;
		ListNode tempNode ;		
		
		if (nodeA == null) {
		    return nodeB;
		  } 
		  if (nodeB == null) {
		    return nodeA;
		  }		
		
	
		if ( nodeA.getValue() < nodeB.getValue())
		{
			mergedNode = nodeA;
			nodeA = nodeA.getNext();
		}
		else
		{
			mergedNode = nodeB;
			nodeB = nodeB.getNext();
		}

		tempNode = mergedNode; 
		
		while (nodeA != null && nodeB != null)
		{			
					
			if ( nodeA.getValue() < nodeB.getValue())
			{				
				mergedNode.setNext(nodeA);
				nodeA = nodeA.getNext();
			}
			else
			{
				mergedNode.setNext(nodeB);
				nodeB = nodeB.getNext();				
			}		
			mergedNode = mergedNode.getNext();
		}
		
		if (nodeA != null)
		{
			mergedNode.setNext(nodeA);
		}
		
		if (nodeB != null)
		{
			mergedNode.setNext(nodeB);
		}		
		return tempNode;
	}