Hey,i'm in trouble with this practiceexercise.you have to modify this class so it is compatible to the generic interface comparable.i dont know how to start and get the first steps.
public interface Comparable<T>
interface looks like i described it above.thank you for your help
Your class worker has to implement the Comparable Interface.
Providing your Class as Generic to the Interface you will have to implement an compareTo() Method, that takes your own class as Argument instead of an Object.
thanks for your advice,now is my code right till now?how should i implement the compareto-Method?anpther question is that i have to implement a method (public static<T extends Comparable<T>> void sort(T[] array)) which sorts with my compareMethode an array filled with objects,which are compatible to interface comparable.how do i do this?thank you
Hey my friend who is able to speak german translated my issue.I alread have read through the list of search result but dont know how to transform my knowledge into a code.
Die Klasse soll so modifiziert werden dass sie das generische interface comparable unterstützt und anschließend soll eine methode public static <T extends Comparable<T>> void sortiere(T[] einArray) erstellt werden die mit der compareTo-Methode das array mit diesen objekten soritert,die natürlich das interface comparable untersützt.danke für euren hilfe
Hey my friend who is able to speak german translated my issue.I alread have read through the list of search result but dont know how to transform my knowledge into a code.
Die Klasse soll so modifiziert werden dass sie das generische interface comparable unterstützt und anschließend soll eine methode public static <T extends Comparable<T>> void sortiere(T[] einArray) erstellt werden die mit der compareTo-Methode das array mit diesen objekten soritert,die natürlich das interface comparable untersützt.danke für euren hilfe
Hey so my problem is that i dont know how to create at first the compareTo-Method,then how to implement the method public static <T extends Comparable<T>> void sort(T[] someArray) which uses my compareTo-method sorting this array fullfilled with objects being compatible to the interface Comparable.thank you for your help
then how to implement the method public static <T extends Comparable<T>> void sort(T[] someArray) which uses my compareTo-method sorting this array fullfilled with objects being compatible to the interface Comparable.
Select a sorting algorithm and apply it to your array. Use sortableArray.compareTo(sortableArray[j]) to decide, if the Elements need to swich their positions.