How to implement a generic `max(Comparable a, Comparable b)` function in Java?

前端 未结 5 1366
遥遥无期
遥遥无期 2020-12-18 20:17

I\'m trying to write a generic max function that takes two Comparables.

So far I have

public static &g         


        
5条回答
  •  渐次进展
    2020-12-18 20:23

    I've written a utility class for this. Maybe you find it useful (the library is Open Source):

    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/util/Comparables.html

    Homepage:

    http://www.softsmithy.org

    Download:

    http://sourceforge.net/projects/softsmithy/files/softsmithy/

    Maven:

      
        org.softsmithy.lib  
        lib-core  
        0.1  
     
    

提交回复
热议问题