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 - ScrollTo Effect (href to div) -

javascript - ng-class not responding to change in model in Angular? -

javascript - document.registerElement extending HTMLInputElement prototype while using custom tag name to avoid implicit browser style -