Doubt in merge two sorted LL

import java.util.*;
class LinkedList {

private class Node {

	int data;
	Node next;
}

private Node head;
private Node tail;
private int size;

public int getFirst() throws Exception {
	if (this.size == 0)
		throw new Exception("linked list is empty");

	return head.data;
}

public int getLast() throws Exception {
	if (this.size == 0)
		throw new Exception("linked list is empty");

	return tail.data;
}

public void addLast(int item) {
	// create a new node
	Node nn = new Node();

	nn.data = item;
	nn.next = null;

	// update summary
	if (size == 0) {
		this.head = nn;
		this.tail = nn;
		size++;
	} else

	{
		this.tail.next = nn;
		this.tail = nn;

		size++;
	}

}

public void addFirst(int item) {
	Node nn = new Node();
	nn.data = item;
	nn.next = null;

	if (size == 0) {
		this.head = nn;
		this.tail = nn;
		size++;
	} else {
		nn.next = this.head;
		this.head = nn;
		size++;
	}

}

public int removeFirst() throws Exception {
	Node fn = this.head;

	if (this.size == 0)
		throw new Exception("linked list is empty");

	if (this.size == 1) {
		this.head = null;
		this.tail = null;
		size = 0;
	} else {
		Node np1 = this.head.next;
		this.head = np1;
		size--;
	}

	return fn.data;
}

public void merge_sorted_list(LinkedList other) throws Exception {

	// write your code here
	LinkedList merged=new LinkedList();
	Node one= this.head;
	Node two= other.head;
	while (one !=null && two!=null) {
		if (one.data <two.data) {
			merged.addLast(one.data);
			one=one.next;
			
		}
		else {
			merged.addLast(two.data);
			two=two.next;
		}
		
		
	}
	if (one ==null) {
		while (two!=null) {
			merged.addLast(two.data);
			two=two.next;
			
		}
	}
	if (two ==null) {
		while (one!=null) {
			merged.addLast(one.data);
			one=one.next;
			
		}
	}
     merged.display();
     
	
}

public void display() {

	Node temp = this.head;

	while (temp != null) {
		System.out.print(temp.data + " ");
		temp = temp.next;
	}

}

static Scanner scn = new Scanner(System.in);

public static void main(String[] args) throws Exception {
	// TODO Auto-generated method stub
	
	    int t = scn.nextInt();
	    
	    while(t > 0){

		    LinkedList list1 = new LinkedList();
		    int n1 = scn.nextInt();
		 
		    for (int j = 0; j < n1; j++) {
			    int item = scn.nextInt();
			    list1.addLast(item);
		}

            LinkedList list2 = new LinkedList();
		    int n2 = scn.nextInt();
		 
		    for (int j = 0; j < n2; j++) {
			    int item = scn.nextInt();
			    list2.addLast(item);
		}
		   list1.merge_sorted_list(list2);

        t--;
        }
	
}

}
what is wrong in my code???

@harsh.hj Hi buddy, simply use a new line after every test case, because multiple test cases are there, your code will be accepted, also the class in which ya main method is present should be named Main.
If your doubt is clear, mark it resolved bro!
Happy coding!

can u elaborate plz what is the problem with my code

plz sent the corrected code because i am not able to understand what you want to say

sir i am getting a run error

@harsh.hj bro here’s ya corrected code, ya logic was write just a new line thing bro, keep the work up!

import java.util.*;
class LinkedList {

private class Node {

int data;
Node next;

}

private Node head;
private Node tail;
private int size;

public int getFirst() throws Exception {
if (this.size == 0)
throw new Exception(“linked list is empty”);

return head.data;

}

public int getLast() throws Exception {
if (this.size == 0)
throw new Exception(“linked list is empty”);

return tail.data;

}

public void addLast(int item) {
// create a new node
Node nn = new Node();

nn.data = item;
nn.next = null;

// update summary
if (size == 0) {
	this.head = nn;
	this.tail = nn;
	size++;
} else

{
	this.tail.next = nn;
	this.tail = nn;

	size++;
}

}

public void addFirst(int item) {
Node nn = new Node();
nn.data = item;
nn.next = null;

if (size == 0) {
	this.head = nn;
	this.tail = nn;
	size++;
} else {
	nn.next = this.head;
	this.head = nn;
	size++;
}

}

public int removeFirst() throws Exception {
Node fn = this.head;

if (this.size == 0)
	throw new Exception("linked list is empty");

if (this.size == 1) {
	this.head = null;
	this.tail = null;
	size = 0;
} else {
	Node np1 = this.head.next;
	this.head = np1;
	size--;
}

return fn.data;

}

public void merge_sorted_list(LinkedList other) throws Exception {

// write your code here
LinkedList merged=new LinkedList();
Node one= this.head;
Node two= other.head;
while (one !=null && two!=null) {
	if (one.data <two.data) {
		merged.addLast(one.data);
		one=one.next;
		
	}
	else {
		merged.addLast(two.data);
		two=two.next;
	}
	
	
}
if (one ==null) {
	while (two!=null) {
		merged.addLast(two.data);
		two=two.next;
		
	}
}
if (two ==null) {
	while (one!=null) {
		merged.addLast(one.data);
		one=one.next;
		
	}
}
 merged.display();

}

public void display() {

Node temp = this.head;

while (temp != null) {
	System.out.print(temp.data + " ");
	temp = temp.next;
}

}
}

class Main {
static Scanner scn = new Scanner(System.in);
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub

    int t = scn.nextInt();
    
    while(t > 0){

	    LinkedList list1 = new LinkedList();
	    int n1 = scn.nextInt();
	 
	    for (int j = 0; j < n1; j++) {
		    int item = scn.nextInt();
		    list1.addLast(item);
	}

        LinkedList list2 = new LinkedList();
	    int n2 = scn.nextInt();
	 
	    for (int j = 0; j < n2; j++) {
		    int item = scn.nextInt();
		    list2.addLast(item);
	}
	   list1.merge_sorted_list(list2);
	   System.out.println();
    t--;
    }

}
}

Happy Coding!
If the doubt is clear do resolve it buddy!