Skip to content

Commit a023542

Browse files
author
asri71
committed
Addint type package to have interfaces to take benefit of polymorphism features
1 parent 5227629 commit a023542

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/main/java/com/sorts/BubbleSort.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package src.main.java.com.sorts;
22

3-
public class BubbleSort {
3+
import src.main.java.com.types.Sort;
4+
5+
public class BubbleSort<T> implements Sort<T> {
46
/**
57
* This method implements the Generic Bubble Sort
68
*
79
* @param array The array to be sorted
810
* Sorts the array in increasing order
911
**/
12+
13+
@Override
1014
public <T extends Comparable<T>> T[] sort(T[] array) {
1115
int last = array.length;
1216
//Sorting

src/main/java/com/types/Sort.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package src.main.java.com.types;
2+
3+
public interface Sort<T> {
4+
5+
public <T extends Comparable<T>> T[] sort(T[] array);
6+
}

0 commit comments

Comments
 (0)