import java.util.Scanner;
public class Main {//字典排序
public static void dictionary(int num) {//输入为字典排序的字符串个数
if (num == 0) {
System.out.println("");
} else {
Scanner scanner = new Scanner(System.in);
String[] str = new String[num];
for (int i = 0; i < num; i++) {//向字符串数组中输入字符串
str[i] = scanner.nextLine();
}
for (int i = 0; i < num - 1; i++) {//排序
String s = str[i];
for (int j = i + 1; j < num; j++) {
if (s.compareTo(str[j]) > 0) {
str[i] = str[j];
str[j] = s;
s=str[i];
}
}
}
for (int i = 0; i < num; i++) {
System.out.println(str[i]);
}
}
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
int num = scanner.nextInt();
dictionary(num);
}
}
}提交显示----->运行错误:请检查是否存在数组越界非法访问,野指针乱访问,空指针乱访问等情况
菜鸟初学Java实在是看不出哪有问题啊,eclipse上运行也没显示有问题,跪求大神指导下,谢谢