next()后面一定不要用nextLine,否则输入必存在问题 解决办法:1.该nextLine()为next() 2.在next()后再加一个nextLine()

import java.util.*;
public class Main{
    public static void main(String args[]) {
    
        Scanner sc=new Scanner(System.in);
            int n =sc.nextInt();
            String[] strs=new String[n];
            for(int i=0;i<n;i++){
                strs[i]=sc.next();//这里不要用nextline()
                /**
                nextLine()不能用在nextInt()的后面!!!!
                //nextLine()自动读取了被next()去掉的Enter作为他的结束符,
                所以没办法从键盘输入值。
                */
           }
             Arrays.sort(strs);//Arrays.sort()自带排序
             for(String str:strs) {
                System.out.println(str);
            
        }
    }
}