Working in Eclipse but here throws InputMismatchException at line 12 please find code

import java.util.*;
public class Main {
public static void main(String args[]) throws Exception{
Scanner sc = new Scanner(System.in);

	int t = sc.nextInt();
	
	while(t>0) {
		
		t--;
		
		int n = sc.nextInt();
		
		List<String> a = new ArrayList<String>();
		
		for(int i =0; i<n;i++) {
			
			String a1 = sc.next();
			
			 a.add(a1);
		}
		LargestNumber(a);
		
		
	}
	
}


public static void LargestNumber(List<String>a ) {
	
	
	Collections.sort(a, new Comparator<String>() {
		
		
		public int compare(String X, String Y) {
			
			String XY = X+Y;
			
			String YX = Y+X;
			int comp = XY.compareTo(YX);
			
			
			if(comp > 0) {
				return -1;
			}else {
				return 1;
			}
			
		}
	});
	
	
	Iterator<String> it = a.iterator();
	
		while(it.hasNext()) {
			System.out.print(it.next());
		}
	
	
}

}

Use sc.nextLine() instead of sc.next().

Used Sc.nextline() now getting Run-error please help

As per my understanding aayega toh sc.next() he, may be i’m wrong

Yes, sorry I forgot to see the input format. You should use sc.next() but just for accepting t and n as well, use sc.nextLine()

I can’t get your point can you please correct my code

your code is correct but you need to go to next line after printing answer for each test case

Still dont get your suggestion

After printing the output for a particular test case, move to new line.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.