Abstract classes implementing comparable

Discussion in 'Mac Programming' started by Mac Player, Mar 2, 2007.

  1. macrumors regular

    Joined:
    Jan 19, 2006
    #1
    Hi,

    Can i implement comparable in an abstract class? This way for example, i could sort of array of objects from different clsses extending the same abstract class. Or maybe not.....
     
  2. macrumors member

    Joined:
    Oct 27, 2003
    #2
    I assume you mean in Java?

    Yes. You can implement a Comparable abstract class. You can also implement a Comparable interface.
     
  3. thread starter macrumors regular

    Joined:
    Jan 19, 2006
    #3
    Thanks. Yes I was talking about java.

    So i can do something like:

    public abstract class xxx implements Comparable
     
  4. macrumors 6502

    Joined:
    Jul 25, 2006
    #4
    Quickest way to find out is to experiment for yourself...
     
  5. macrumors member

    Joined:
    Oct 27, 2003
    #5
    Basically yes, but use generics ~_^

    Why not just try it and see?
     

Share This Page