Import the Java. Util. Collections;
Import the Java. Util. LinkedList;
import java.util.Scanner;
Public class WordSortAaToZz {
Public static void main (String [] args) {
Scanner in=new Scanner(System.in);
While (in) hasNext ()) {
String String=in nextLine ();
LinkedList
Char [] cs=strig. ToCharArray ();
for(int i=0; i
System. The out. Print (list. Get (j));
j++;
} else {
System. The out. Print (cs) [I];
}
}
}
System.out.println();
}
}
}
CodePudding user response:
//the List sorted ignore casePublic List
The Collections. The sort (list, new Comparator
@ Override
Public int the compare (String s1, String s2) {
Return to s1.com pareToIgnoreCase (s2);
}
});
return list;
}
CodePudding user response:
You can try this:
String [] array={" b ", "A", "D", "c"};
Arrays. Sort (array, String. CASE_INSENSITIVE_ORDER);
System. The out. Println (EntityUtil. ToJson (array));
The console print:
[" A ", "b", "c", "D"]
CodePudding user response: