Addint type package to have interfaces to take benefit of polymorphism features

This commit is contained in:
asri71 2019-02-28 16:57:18 +05:30
parent 5227629d3e
commit a023542464
2 changed files with 11 additions and 1 deletions

View File

@ -1,12 +1,16 @@
package src.main.java.com.sorts; package src.main.java.com.sorts;
public class BubbleSort { import src.main.java.com.types.Sort;
public class BubbleSort<T> implements Sort<T> {
/** /**
* This method implements the Generic Bubble Sort * This method implements the Generic Bubble Sort
* *
* @param array The array to be sorted * @param array The array to be sorted
* Sorts the array in increasing order * Sorts the array in increasing order
**/ **/
@Override
public <T extends Comparable<T>> T[] sort(T[] array) { public <T extends Comparable<T>> T[] sort(T[] array) {
int last = array.length; int last = array.length;
//Sorting //Sorting

View File

@ -0,0 +1,6 @@
package src.main.java.com.types;
public interface Sort<T> {
public <T extends Comparable<T>> T[] sort(T[] array);
}