java编程实现:对输入的10个字符串进行按字母顺序排序
展开全部
package string;
import java.util.Arrays;
import java.util.Scanner;
public class SortDemo
{
public static void main(String[] args)
{
String[] strings = new String[10];
Scanner scanner = new Scanner(System.in);
for (int i = 0; i < strings.length; i++)
{
System.out.println("请输入第" + (i + 1) + "个字符串:");
strings[i] = scanner.nextLine();
}
Arrays.sort(strings);
System.out.println(Arrays.toString(strings));
}
}
import java.util.Arrays;
import java.util.Scanner;
public class SortDemo
{
public static void main(String[] args)
{
String[] strings = new String[10];
Scanner scanner = new Scanner(System.in);
for (int i = 0; i < strings.length; i++)
{
System.out.println("请输入第" + (i + 1) + "个字符串:");
strings[i] = scanner.nextLine();
}
Arrays.sort(strings);
System.out.println(Arrays.toString(strings));
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询