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

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

Redirect to a HTTPS version using .htaccess -