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
虚拟机中,被加载类型的信息都保存在方法区中。这些信息在内存中的组织形式由虚拟机的实现者定义,比如,虚拟机工作在一个“little- endian”
的处理器上,他就可以将信息保存为“little-endian”
格式的,虽然在Java
类文件中他们是以“big-endian”
格式保 存的。设 ......
一、JSON 是什么?
JSON 的全称是JavaScript Object Notation,是一种轻量级的数据交换格式。
JSON 与XML 具有相同的特性,例如易于人编写和阅读,易于机器生成和解析。但是JSON 比
XML 数据传输的有效性要高出很多。JSON 完全独立与编程语言,使用文本格式保存。
JSON 数据有两种结构:
• Name-Value 对构成的集 ......
首先需要知道的是,MP3文件的文件信息都放在文件最后的128个字节里面,这128个字节分别存储的信息如下:
char Header[3]; /* 标签头必须是"TAG"否则认为没有标签 */
char Title[30]; /* 标题 */
char Artist[30]; /* 作者&n ......
MySQL Java 开发套装(服务器,管理工具,JDBC驱动,示例代码)
小更新: 为了减轻负担, 用 MySQL-Front 2.5 来管理, 这个软件无中文问题. 如果以后开源版本HeidiSQL的解决了中文问题, 就用开源的.
下载: http://tomcatmonitor.googlecode.com/files/portable_mysql5.exe 4.02MB (自解压包)
参考文档: MySQL 5 绿色 ......
1. 代理模式主要有两种:静态代理和动态代理
2. 静态代理:
比如要在输出“HelloWorld”前打印一个字符串“Welcome”
A:先定义一个接口类
Java代码
package ttitfly.proxy;
public interface HelloWo ......