import java.util.*; class Example { public static void bubbleSort(int[] a) { for (int k=a.length-1; k>0; k--) { for (int i=0; ia[i+1]) { int temp=a[i]; a[i]=a[i+1]; a[i+1]=temp; } System.out.println(Arrays.toString(a)); try { Thread.sleep(500); } catch(Exception e){} } } } public static void main(String args[]) { int[] ar={98,78,56,34,23,58,21,67,37,8}; System.out.println(Arrays.toString(ar)); bubbleSort(ar); System.out.println(Arrays.toString(ar)); } }
The post How i turn this programme in selection sort appeared first on BlogoSfera.