public static void main(String[] args)
{
boolean needReInput = true;
String input = "";
String first = "";
String secord = "";
while(needReInput){
System.out.println("请输入一个小于10个字符的字符串");
Scanner scanner = new Scanner(System.in);
input = scanner.next();
needReInput = input.length() >= 10;
if (!needReInput){
System.out.println("请输入指定字符串");
first = scanner.next();
needReInput = input.indexOf(first) == -1;
if (!needReInput) {
System.out.println("请输入另一指定字符串");
secord = scanner.next();
needReInput = input.indexOf(secord) == -1;
}
}
scanner.close();
}
char[] charArray = input.toCharArray();
Arrays.sort(charArray);
System.out.println("从小到大排序:"+Arrays.toString(charArray));
System.out.println(input.substring(input.indexOf(first), input.indexOf(secord)+1));
}
冒泡排序重载小于号为比较函数