reset password
Author Message
Arnav98
Posts: 48
Posted 11:52 Feb 02, 2018 |

Can we use the compareTo method in our sorting class? 

kknaur
Posts: 540
Posted 12:15 Feb 02, 2018 |

Part of the requirement of the Sorting method is that the generic is bounded by Comparable.  This ensures that any objects we want to sort with that method must have implemented the Comparable interface.  This means that yes, inside the sort method you will need to use the compareTo method of Comparable.

RandomAccess
Posts: 101
Posted 21:50 Feb 04, 2018 |

By bounded do you mean "implements Comparable<E>" next to the public class with E being the generic type?

kknaur
Posts: 540
Posted 06:10 Feb 05, 2018 |

Review the lecture / readings  for what a bound is for Generics.