Im having trouble implementing my own ordered linked list from scratch.

public class LinkedList{
	
	
	Node head,tail;
	
	public LinkedList(){
		
		head=tail=null;
	
	}
	
	
	public LinkedList(Node node){
		
		this.head=new Node(node.num);
		this.tail=new Node(node.num);
		
	}
	
	public static void main(String[] args){
		
		
		LinkedList list=new LinkedList();
	
		list.insert(new Node(7));
		list.insert(new Node(3));
		
	}
	
	
	
	public void insert(Node node){
		
		
		if(head==null){
			
			head=node;
			tail=node;
		}
		
		
		else{
			
			if(node.num<head.num){
				
			
				
				
				
			}
			
			
			
			
		}
		
		
	}
	
	}

my trouble is lets say i want to insert 7 then 3 like above;

7 is the head and tail. then 3 < 7 so i need to make the head point to 3, tail to 7.
but then insert 1, how to accomidate??

Have you taken a piece of paper and pencil and worked out the details on how the pointers change when working with a LL?

insert 1, how to accomidate

Where should the pointers be after a 1 is inserted?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.