No more nonsense, directly to everyone code sharing code.
The specific code looks like this:
package test;/** * * @Title Information class * @author LR * @version. * @since-*/Public Clas S book {private string book_id; private string book_name; private string publishing_house. Public Book (String book_id, St Ring Book_name, String Publishing_house) {super (); this.book_id = book_id; this.book_name = book_name; this.publishing_ho
Use = Publishing_house; Public String getbook_id () {return book_id.} public void setbook_id (String book_id) {this.book_id = book_id; String Getbook_name () {return book_name.} public void Setbook_name (string book_name) {this.book_name = Book_name;} pu
Blic String Getpublishing_house () {return publishing_house.} public void Setpublishing_house (string publishing_house) {
This.publishing_house = Publishing_house; @Override public String toString () {//TODO auto-generated Method Stub return ISBN "+book_id+" \ n title "+book_name+" \ n Publishing House +pub
Lishing_house; }
}
package test;
import java.text.Collator/** * * @Title Chinese string sorting function * @author LR * @version. * @since
--* * Import java.util.ArrayList;
Import java.util.Collections;
Import Java.util.Comparator; public class Collectionchinesesort implements comparator<book>{collator collator= collator.getinstance (
Java.util.Locale.CHINA); public static void Main (string[] args) {arraylist<book> list=new arraylist<book> (); List.add (new book ("", "
English "," English publishing House "));
List.add (New book ("", "Japanese", "Japanese Press"));
List.add (New book ("", "German", "German publishing House"));
List.add (New book ("", "French", "French Press"));
List.add (New book ("", "Russian", "Russian Publishing House"));
Collections.sort (List,new collectionchinesesort ());
for [book Book:list] {System.out.println (book); @Override public int Compare (book book, Book book) {//TODO auto-generated method stub int compare_value=collator.co
Mpare (Book.getbook_name (), Book.getbook_name ());
if (compare_value>) {return;} if (compare_value<) {return-;} return; }
}
The above content is a small series to introduce the Java implementation of the Chinese character string code, I hope to help you!