whatIs

what is comparable in Java

Hierarchy package: java.lang.Comparable Definition Sorting interface that designed for a condition by overriding compareTo method. For example, you can sort list in ascending order of size. about the compareTo() method if compareTo() method return positive number, swap the input parameters else will be remain same condition return First parameter < second parameter negative First parameter == second parameter 0 First parameter > second parameter positive How to use customObject implements Comparable<>

what is comparator in Java

Hierarchy package: java.util.Comparator Definition Sorting interface that designed for mutiple special conditions by creating compare method. For example, you can sort list in ascending order of size and descending order of letters. about the compare() method if compare() method return positive number, swap the input parameters else will be remain same condition return First parameter < second parameter negative First parameter == second parameter 0 First parameter > second parameter positive How to use MyComparator implements Comparator<>

What is Algorithm

Definition specific method of solving the problem the problem: It need to be clear. input and output is stated in exact range. specific method: If you do not know how to solve that problem, you can solve it with specific steps. Example If you get drink from a vending machine, put cash select drink get drink This is kind of algorithm. However, it specfic enough for computers. get $3 cash from wallet find input location insert cash into the cending machine check how many kinds of drink choose drink what you want push button for the drink pick up the drink.