java - Trying to learn generics, is there a way to see if one generic object is bigger or smaller then another? -


i thought nice use generics write quick sort. i'm learning generics, , seems can test whether 1 generic value equal another. there way see if 1 greater another? wrote simple isbig method follows

public boolean  isbigger( t b) {         if (b>x) // error message here             return true;          return false; } 

public static <t extends comparable<? super t>> boolean isbigger(t x, t y) {   return x != null && (y == null || x.compareto(y) > 0); }  public static <t> boolean isbigger(t x, t y, comparator<? super t> cmp) {   return cmp.compare(x, y) > 0; } 

Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -