Bubble Sort Program in Java
class Bubble_sort { public static void main(String args[]) { int a[]={3, 8, 1, 6}; int temp; for(int x=0; x<(a.length-1); x++) { for(int y=x; y<a.length; y++) { if(a[x]>a[y]) { a[x]=a[y]; a[y]=temp; } } } for(int i=0; i<a.length; i++) { System.out.println(" "+a[i]); } } }