Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. abstract class Parent<T>
  2. {
  3. public T a[];
  4. public abstract void sort(T a[]);
  5. public abstract void searc(T a[]);
  6. }
  7. class B_Sort<T> extends Parent<T>
  8. {
  9.  
  10. @Override
  11. public void sort(T[] a) {
  12. for(int i =1; i< a.length; i++){
  13. for(int j = 0; j < (a.length - i); j ++){
  14. if((((Comparable) (a[j])).compareTo(a[j+1])) > 0){
  15. T tmp = a[j];
  16. a[j] = a[j + 1];
  17. a[j + 1] = tmp;
  18. }
  19. }
  20. }
  21. }
  22. @Override
  23. public void searc(T[] a) {
  24. }
  25.  
  26. }
  27.  
  28. public class ProjectX {
  29.  
  30. public static void main(String[] args) {
  31. int [] a={2,3,1,5};
  32. Parent<Integer> cc=new B_Sort<>();
  33. cc.sort(a);
  34.  
  35. }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement