Java reviews 003 sorting, java reviews 003 sorting
Jump from java review 003
For the C language implementation version, see some-sort-algorithms.
Address: http://vview.ml/2014/04/13/some-sort-algorithms-java.html
Written by Vell Bibi posted at VBlog
Java: A question for small exercise questions in alphabetical order.
Just set one. Don't laugh.
Public static void main (String [] args ){
String str = "cat ";
Char [] c = str. toCharArray ();
Int len = c. length;
For (int I = 1; I <len; I ++ ){
// String Buffer
StringBuilder sb = new StringBuilder ();
Sb. append (c [I]);
// Ordered
For (int j = 0; j <len; j ++ ){
If (j = I ){
Continue;
}
Sb. append (c [j]);
}
System. out. println (sb. toString ());
}
For (int I = 0; I <len; I ++ ){
StringBuilder sb = new StringBuilder ();
Sb. append (c [I]);
// Sort in reverse order
For (int j = len-1; j> = 0; j --){
If (j = I ){
Continue;
}
Sb. append (c [j]);
}
System. out. println (sb. toString ());
}
}
I am a beginner in java. I just wrote a exercise question, but I used CompareTo to sort the questions. How can I compile it in Eclipse,
Public static void main (String [] args ){
String info = "Zhang San: 21: 98 | Li Si: 32: 33 | Wang Wu: 32: 23 ";
String s [] = info. split ("\\| ");
For (int I = 0; I <s. length; I ++ ){
String t = s [I]. toString (). substring (s [I]. length ()-2, s [I]. length ());
Integer. parseInt (t); // converts a string to an Integer.
// Then compare
}
}