java - how comparable interface return int value, if an interface having only method declaration -
string s1="aaa"; string s2="bbb"; int result_int = s1.compareto(s2);
the result_int -ve value, means .compareto
method says s1 lesser s2. question is=> if .compareto
method comparable interface,then interface method how should have body?? if compareto
method doesn't have body, how return integer value while passing 2 objects.
compareto method have implementation. method implemented in classes such integer, double etc. in case using string's compareto method.
if want customized per class, overriding compareto method.
Comments
Post a Comment