易截截图软件、单文件、免安装、纯绿色、仅160KB

Object Ordering java 排序

Object Ordering
A List l may be sorted as follows.
Collections.sort(l);
If the List consists of String elements, it will be sorted into alphabetical order. If it consists of Date elements, it will be sorted into chronological order. How does this happen? String and Date both implement the Comparable interface. Comparable implementations provide a natural ordering for a class, which allows objects of that class to be sorted automatically. The following table summarizes some of the more important Java platform classes that implement Comparable.
Classes Implementing Comparable
ClassNatural Ordering
Byte
Signed numerical
Character
Unsigned numerical
Long
Signed numerical
Integer
Signed numerical
Short
Signed numerical
Double
Signed numerical
Float
Signed numerical
BigInteger
Signed numerical
BigDecimal
Signed numerical
Boolean
Boolean.FALSE < Boolean.TRUE
File
System-dependent lexicographic on path name
String
Lexicographic
Date
Chronological
CollationKey
Locale-specific lexicographic
If you try to sort a list, the elements of which do not implement Comparable, Collections.sort(list) will throw a ClassCastException. Similarly, Collections.sort(list, comparator) will throw a ClassCastException if you try to sort a list whose elements cannot be compared to one another using the comparator. Elements that can be compared to one another are called mutually comparable. Although elements of different types may be mutually comparable, none of the classes listed here permit interclass comparison.
This is all you really need to know about the Comparable interface if you just want to sort lists of comparable elements or to create sorted collections of them. The next section will be of interest to you if you want to implement your own Comparable type.
Writing Your Own Comparable Types
The Comparable interface consists of the following method.
public interface Comparable<T> {
public int compareTo(T o);
}
The compareTo method c


相关文档:

java数据结构之树集TreeSet与书映射(TreeMap)

1.树集TreeSet
     TreeSet类在java.util包中
     树集中的结点是按着其存放的数据的字典序一层一层地依次排列  在同一层中的结点从左到右按字典序递增排列
     A.构造方法:TreeSet()
     B.常用方法
   & ......

java数据结构之散列集HashSet与散列表Hashtable

1.散列集HashSet
     HashSet类在java.util包中
     A.构造方法:HashSet()
     B.常用方法
          public boolean add(Object o):向集合中添加指定元素o
      &nb ......

java中使用dom4j写xml文件和简单教程

 
下载 dom4j-1.6.1.jar。
1: package org.zzp.common.xml.dom4j;
2:
3: import java.io.FileWriter;
4: import java.io.IOException;
5: import org.dom4j.Document;
6: import org.dom4j.DocumentHelper;
7: import org.dom4j.Element;
8: import org.dom4j.io.OutputFormat;
9: impor ......

java 解析MP3文件


首先需要知道的是,MP3文件的文件信息都放在文件最后的128个字节里面,这128个字节分别存储的信息如下:
char Header[3];    /* 标签头必须是"TAG"否则认为没有标签 */
char Title[30];    /* 标题 */
char Artist[30];   /* 作者&n ......

java SSL安全socket的通讯实例 java学习笔记(4)

学习了SSL的基本原理后..动手用java来实现了一个安全连接的实例..
1.使用keytool创建密钥对..并在服务端和客户端完成分配..具体方法可参看:java-使用keytool来创建管理密钥及证书等-java学习笔记(3)
2.建立客户端和服务端的socket实例:
客户端代码如下:
public class SSLClient {
public static void startSSLClie ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号