Why my code doesn't work

import java.util.*;

public class Main

{public static void main(String args[]) {

Scanner sc = new Scanner(System.in);

PriorityQueue<String> pq=new PriorityQueue<>();
int t=sc.nextInt();sc.nextLine();
while(t-->0) {
	pq.add(sc.nextLine());
}
while(pq.size()!=0) {
	System.out.println(pq.poll());
}
}

}

Hey @akshatj07
you doing wrong
3
bat
apple
batman
correct output :
apple
batman
bat
if a string is present completely as a prefix in another string, then string with longer length should come first.