本帖最后由 whd3331933 于 2010-03-24 18:17:16 编辑

解决方案 »

  1.   

    這樣做可以阿
    然后collections.sort(myList)
      

  2.   

    对的  要排序就要集成Comparable 接口并重写ComparaTo方法
      

  3.   

    是不是 如果我调用如下类的对象 就不用重写 ComparaTo方法啦 Authenticator.RequestorType, BigDecimal, BigInteger, Boolean, Byte, ByteBuffer, Calendar, Character, CharBuffer, Charset, CollationKey, CompositeName, CompoundName, Date, Date, Double, DoubleBuffer, ElementType, Enum, File, Float, FloatBuffer, Formatter.BigDecimalLayoutForm, FormSubmitEvent.MethodType, GregorianCalendar, IntBuffer, Integer, JTable.PrintMode, KeyRep.Type, LdapName, Long, LongBuffer, MappedByteBuffer, MemoryType, ObjectStreamField, Proxy.Type, Rdn, RetentionPolicy, RoundingMode, Short, ShortBuffer, SSLEngineResult.HandshakeStatus, SSLEngineResult.Status, String, Thread.State, Time, Timestamp, TimeUnit, URI, UUID --------------------------------------------------------------------------------
      

  4.   

    不对 应该这样说 是不是如果 List容器里 装着 如下类的元素 就不用重写这个方法了 我自己新建的类 就得重写 
    Authenticator.RequestorType, BigDecimal, BigInteger, Boolean, Byte, ByteBuffer, Calendar, Character, CharBuffer, Charset, CollationKey, CompositeName, CompoundName, Date, Date, Double, DoubleBuffer, ElementType, Enum, File, Float, FloatBuffer, Formatter.BigDecimalLayoutForm, FormSubmitEvent.MethodType, GregorianCalendar, IntBuffer, Integer, JTable.PrintMode, KeyRep.Type, LdapName, Long, LongBuffer, MappedByteBuffer, MemoryType, ObjectStreamField, Proxy.Type, Rdn, RetentionPolicy, RoundingMode, Short, ShortBuffer, SSLEngineResult.HandshakeStatus, SSLEngineResult.Status, String, Thread.State, Time, Timestamp, TimeUnit, URI, UUID --------------------------------------------------------------------------------
      

  5.   

    List的Sort方法使用对象类中Comparable接口的CompareTo()方法来实现排序处理,
      

  6.   

    Name里新建了个list对象如果我要实现List对象的排序 是不是 我这个类要继承 Comparable 接口 然后重写 接口里ComparaTo的方法呢 
    =================
    list对象里面放的是什么对象呢
    1.是Name对象,,就实现Comparable接口 重写CompareTo()方法
    2.普通类型,那就collections.sort(list)