题解 | #字符串排序#
字符串排序
http://www.nowcoder.com/practice/5af18ba2eb45443aa91a11e848aa6723
注意要消耗掉换行符
import java.util.*; public class Main{ public static void main(String[] args){ Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); scanner.nextLine(); //消耗掉换行符 String[] strs = new String[n]; for(int i = 0; i < n; i++){ strs[i] = scanner.nextLine(); } Arrays.sort(strs); for(String str : strs){ System.out.println(str); } } }