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
Ïà¹ØÎĵµ£º
¼ÇµÃµÚÒ»´Î½Ó´¥±Õ°üµÄʱºò£¬¾õµÃºÜÆæ¹Ö£¬µ«´Ó×ÖÃæÉϺÜÄÇÀí½â±Õ°üʲôÍæÒ⣬ºÍ±Õ°üÓеÄÒ»±ÈµÄµ±Êô¿ØÖÆ·´×ª£¬ÕæÕýÀí½âÁ˺ó¾õµÃ¾Íƽ³£ÁË¡£±Õ°ü¶þ×ÖÆäʵÊǺܾµäµÄ£¬±Õ°ü´úÂëËù±íÏֵĶ«Î÷¿É²»¾ÍÊÇÒ»¸ö·â±ÕµÄ¡¢×Ô³ÉÒ»ÌåµÄ¹¦ÄÜ¿éÂ𣿼òµ¥µÄ˵£¬±Õ°ü¾ÍÊÇÔÚÄÚ²¿¶¨ÒåµÄ·½·¨£¬Äõ½ÍâÃæȥʹÓ᣾µäµÄjavascript±Õ°üÐÎʽÈçÏ£º
Java´ú ......
/**
* ÏÂÔØÎļþ
* @param filePath --ÎļþÍêÕû·¾¶
* @param response --HttpServletResponse¶ÔÏó
*/
public static void downloadFile(
String filePath,
javax.servlet.http.HttpServletResponse response) {
String fileName = ""; //ÎļþÃû£¬Êä³öµ½Óû§µÄÏÂÔضԻ°¿ò
//´ÓÎļþÍêÕû·¾¶ÖÐÌáÈ¡ÎļþÃû£¬²¢½øÐбà ......
MySQL Java ¿ª·¢Ì××°(·þÎñÆ÷,¹ÜÀí¹¤¾ß,JDBCÇý¶¯,ʾÀý´úÂë)
С¸üÐÂ: ΪÁ˼õÇḺµ£, Óà MySQL-Front 2.5 À´¹ÜÀí, Õâ¸öÈí¼þÎÞÖÐÎÄÎÊÌâ. Èç¹ûÒÔºó¿ªÔ´°æ±¾HeidiSQLµÄ½â¾öÁËÖÐÎÄÎÊÌâ, ¾ÍÓÿªÔ´µÄ.
ÏÂÔØ: http://tomcatmonitor.googlecode.com/files/portable_mysql5.exe 4.02MB (×Ô½âѹ°ü)
²Î¿¼Îĵµ: MySQL 5 ÂÌÉ« ......
¿çƽ̨ÈýάͼÐοª·¢¹¤¾ß°üJava 3D
¹Ù·½Ö÷Ò³£ºhttps://java3d.dev.java.net/
Java 3DÑϸñ×ñÑ“½¨Ä££»æÖÆ”·ºÐÍ¡£³¡¾°Í¼£¨scene graph£©µÄ³éÏóÄ£Ðͱ»ÓÃÀ´×éÖ¯ºÍά»¤ÐéÄⳡ¾°ÖеĿÉÊǶÔÏó¼°ÆäÐÐΪ¡£³¡¾°Í¼°üº¬ÁËÐéÄâͼÐÎÊÀ½çµÄÈ«²¿ÐÅÏ¢£¬Java 3D»æÖÆÒýÇæ»á¶Ô³¡¾°Í¼½øÐÐ×Ô ......
ʹÓÃÀàjava.io.File
1.»ñȡϵͳӲÅÌÐÅÏ¢£º
public static String getDiskInfo() {
StringBuffer sb=new StringBuffer();
File[] roots = File.listRoots();// »ñÈ¡´ÅÅÌ·ÖÇøÁбí
for (File file : roots) {
long totalSpace=file.getTotalSpace();
long freeSpace=file.getFreeSpace();
long usa ......