I have read some program code written in Java over the past few days and found many API functions that I did not know before. I thought I was still an intermediate Java language learner. Now it seems that I am only a beginner Java learner. My Understanding of Java has always been on the surface of Java, to solve some application problems, you just need to use some known common interfaces and data structures without learning more about the language. In fact, Java provides many functions and very powerful interfaces, which can easily solve some practical problems for us. The following describes several Java API functions I have recently learned.
I. Sorting
When writing Java programs, we often encounter sorting problems. People who have not studied Java in depth usually choose two methods, the first is to find a code on the Internet and use it in your own program after modification. The second is to write one by yourself. Of course, if you understand the code found on the Internet in the first method, you may find that you are a serious person, I have a deep research on some sorting algorithms, but if you do not write a very subtle sorting algorithm, but just write an ordinary choice, bubble, insert, or more advanced heap, fast, merge, and other algorithms. When you are familiar with these algorithms, it doesn't make much sense to write by yourself. On the contrary, it will waste a lot of time.
In fact, the Java language has already considered the sorting requirements for its users and provided function calls for set sorting, as shown below:
Java. util. arrays. Sort (INT [])
Java. util. arrays. Sort (INT [], Int, INT)
Java. util. arrays. Sort (T [], Int, Int, java. util. comparator)
Java. util. arrays. Sort (T [], java. util. comparator)
Java. util. Collections. Sort (Java. util. List)
Java. util. Collections. Sort (Java. util. List, java. util. comparator)
The above lists the function interfaces that may be frequently used, and some other overloaded functions. If you are interested, you can check the API instructions. The following is an example:
// Sort the set
Public class arraysort {
// Sort the Integer Set
Public void sortintarray (){
Int [] array = new int [] {8, 5, 9, 0, 6, 3, 4, 7, 2, 1 };
System. Out. println ("Before sorting integers ");
For (INT I = 0; I 0)
Return 1;
If (diff 0 ){
Return 1;
} Else if (diff
Previous Article: JDK 64-bit installation under Solaris sparcv9
Next article: transferred a piece of information about Hibernate query, which is very good.