Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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±Õ°üµÄÁíÒ»ÖÖÐÎʽ

¼ÇµÃµÚÒ»´Î½Ó´¥±Õ°üµÄʱºò£¬¾õµÃºÜÆæ¹Ö£¬µ«´Ó×ÖÃæÉϺÜÄÇÀí½â±Õ°üʲôÍæÒ⣬ºÍ±Õ°üÓеÄÒ»±ÈµÄµ±Êô¿ØÖÆ·´×ª£¬ÕæÕýÀí½âÁ˺ó¾õµÃ¾Íƽ³£ÁË¡£±Õ°ü¶þ×ÖÆäʵÊǺܾ­µäµÄ£¬±Õ°ü´úÂëËù±íÏֵĶ«Î÷¿É²»¾ÍÊÇÒ»¸ö·â±ÕµÄ¡¢×Ô³ÉÒ»ÌåµÄ¹¦ÄÜ¿éÂ𣿼òµ¥µÄ˵£¬±Õ°ü¾ÍÊÇÔÚÄÚ²¿¶¨ÒåµÄ·½·¨£¬Äõ½ÍâÃæȥʹÓ᣾­µäµÄjavascript±Õ°üÐÎʽÈçÏ£º
Java´ú ......

ÈçºÎ ʹÓà java ²Ù×Ý XML Îļþ


Introduction to XML and XML With Java  
 
If you are looking for sample programs to parse a XML file using DOM/SAX parser or looking for a program to generate a XML file please proceed directly to programs.
This small tutorial introduces you to the basic concepts of XML and using Xer ......

´Ó2010Ä꿪ʼÎÒѧϰJava¼¼Êõ!

    ÔÚµ±½ñÕâ¸öʱ´ú,ÒªÏëÄܹ»ºÜºÃµÄÉú´æ,¾ÍµÃÓÐ×ã¹»µÃʵÁ¦,ÓÐÄܹ»¿¿µÄסµÄ¼¼Êõ,ÔÚ´óѧѧÁËÁ½Äê°ëµÄÈí¼þ¹¤³Ìרҵ,ÓÐÁ˺ܶàµÄÌå»á,ѧÁ˺ܶàûÓÐÓõĶ«Î÷,ÓÐһЩËäÈ»ÊǺÜÓÐÓÃ,µ±ÊÇÓÖ²»ÊÇÒ»Á½ÄêÄÚÄÜÓõÄÉϵÄ֪ʶ,ËùÒÔÎҾ͵Ã×Ôѧ,ѧʲôÄØ?ѧÓÐʹÓõö«Î÷,Äܹ»ÎªÈÕºóµÄ¹¤×÷ÓõÄÉϵÄ֪ʶ,Õâô³¤Ê±¼äµÄÌå»áºó,ÎÒ·¢Ï ......

JAVAµÄÈÝÆ÷ List,Map,Set

JAVAÈÝÆ÷
¡¡¡¡½âÊÍÒ»£º
¡¡¡¡ÈÝÆ÷£¨Container£©
¡¡¡¡Spring ÌṩÈÝÆ÷¹¦ÄÜ£¬ÈÝÆ÷¿ÉÒÔ¹ÜÀí¶ÔÏóµÄÉúÃüÖÜÆÚ¡¢¶ÔÏóÓë¶ÔÏóÖ®¼äµÄÒÀÀµ¹Øϵ£¬Äú¿ÉÒÔʹÓÃÒ»¸öÅäÖÃÎļþ£¨Í¨³£ÊÇXML£©£¬ÔÚÉÏÃ涨ÒåºÃ¶ÔÏóµÄÃû³Æ¡¢ÈçºÎ²úÉú£¨Prototype ·½Ê½»òSingleton ·½Ê½£©¡¢Äĸö¶ÔÏó²úÉúÖ®ºó±ØÐëÉ趨³ÉΪij¸ö¶ÔÏóµÄÊôÐԵȣ¬ÔÚÆô¶¯ÈÝÆ÷Ö®ºó£¬ËùÓÐ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ