Hi there is problem in image displaying. So I can not see the diagram. But I can tell you what will happen when you reverse the steps; 1. front = node after this line, front of main list poinitng to new node \'node\', so now we have only one element in list. so, node and front point to same element in list 2. node.setNext(front); since node and front is same, so after this line node will point to itself, means create a loop of one element. Solution Hi there is problem in image displaying. So I can not see the diagram. But I can tell you what will happen when you reverse the steps; 1. front = node after this line, front of main list poinitng to new node \'node\', so now we have only one element in list. so, node and front point to same element in list 2. node.setNext(front); since node and front is same, so after this line node will point to itself, means create a loop of one element..