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
Ïà¹ØÎĵµ£º
Ò»¡¢JSON ÊÇʲô£¿
JSON µÄÈ«³ÆÊÇJavaScript Object Notation£¬ÊÇÒ»ÖÖÇáÁ¿¼¶µÄÊý¾Ý½»»»¸ñʽ¡£
JSON ÓëXML ¾ßÓÐÏàͬµÄÌØÐÔ£¬ÀýÈçÒ×ÓÚÈ˱àдºÍÔĶÁ£¬Ò×ÓÚ»úÆ÷Éú³ÉºÍ½âÎö¡£µ«ÊÇJSON ±È
XML Êý¾Ý´«ÊäµÄÓÐЧÐÔÒª¸ß³öºÜ¶à¡£JSON ÍêÈ«¶ÀÁ¢Óë±à³ÌÓïÑÔ£¬Ê¹ÓÃÎı¾¸ñʽ±£´æ¡£
JSON Êý¾ÝÓÐÁ½Öֽṹ£º
• Name-Value ¶Ô¹¹³ÉµÄ¼¯ ......
ʹÓÃWindows²Ù×÷ϵͳµÄÅóÓѶÔExcel£¨µç×Ó±í¸ñ£©Ò»¶¨²»»áÄ°Éú£¬µ«ÊÇҪʹÓÃJavaÓïÑÔÀ´²Ù×ÝExcelÎļþ²¢²»ÊÇÒ»¼þÈÝÒ×µÄÊ¡£ÔÚWebÓ¦ÓÃÈÕÒæÊ¢ÐеĽñÌ죬ͨ¹ýWebÀ´²Ù×÷ExcelÎļþµÄÐèÇóÔ½À´Ô½Ç¿ÁÒ£¬Ä¿Ç°½ÏΪÁ÷ÐеIJÙ×÷ÊÇÔÚJSP»òServlet Öд´½¨Ò»¸öCSV £¨comma separated values£©Îļþ£¬²¢½«Õ⸠......
Java 3DËäÈ»ÄÜÖ§³ÖÖÚ¶àµÄÍⲿ3DÄ£ÐÍÎļþ£¬µ«ÄÜÖ§³Ö±»Java 3DʹÓõÄÍⲿģÐÍÎļþ½öΪ.objºÍ.lwdÁ½ÖÖ£»·Ö±ð¶ÔÓ¦ObjectFileÀàºÍLw3dLoaderÀà¡£Ïà±È֮ϼ¸¿îÖ÷Á÷µÄ3D½¨Ä£Èí¼þ¶¼ÄÜÉú³É.obj¸ñʽµÄÎļþ£¬Òò´Ë±¾ÎÄÖ÷Òª½éÉÜʹÓÃObjectFileÀàÔØÈë.objÎļþµÄ·½·¨¡£
ObjectFileÀàÓÐÈý¸ö¹¹Ôì·½·¨£¬·Ö±ðΪ£º
ObjectFile()
ObjectFile( ......
Èç¹ûÄãÔø¾ÓùýPerl»òÈκÎÆäËûÄÚ½¨ÕýÔò±í´ïʽ֧³ÖµÄÓïÑÔ£¬ÄãÒ»¶¨ÖªµÀÓÃÕýÔò±í´ïʽ´¦ÀíÎı¾ºÍÆ¥ÅäģʽÊǶàô¼òµ¥¡£Èç¹ûÄã²»ÊìϤÕâ¸öÊõÓÄÇô“ÕýÔò±í´ïʽ”£¨Regular Expression£©¾ÍÊÇÒ»¸ö×Ö·û¹¹³ÉµÄ´®£¬Ëü¶¨ÒåÁËÒ»¸öÓÃÀ´ËÑË÷Æ¥Åä×Ö·û´®µÄģʽ¡£
Ðí¶àÓïÑÔ£¬°üÀ¨Perl¡¢PHP¡¢Python¡¢JavaScriptºÍJScript£¬¶¼Ö§ ......