Java reviews 003 sorting, java reviews 003 sorting

Source: Internet
Author: User

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
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.