<span style= "FONT-SIZE:18PX;" >package two.java.test;/** * Bubble sort the basic C language when the first touch is bubble sort * Also called bubble sort but I still like to call bubble sort */public class Bubblesort{public static void Main (String args[]) { int []intarray={12,11,45,6,8,43,40,57,3,20}; SYSTEM.OUT.PRINTLN ("Array before sorting:"); for (int i=0;i<intarray.length;i++) System.out.print (intarray[i]+ ""); System.out.println (); int temp; for (int i=0;i<intarray.length;i++) {for (int j=i;j<intarray.length;j++) { if (intarray[j]<intarray [i]) { temp=intarray[i]; INTARRAY[I]=INTARRAY[J]; Intarray[j]=temp ; }}} System.out.println ("sorted array:"); for (int i=0;i<intarray.length;i++) System.out.print (intarray[i]+ "");}} </span>
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Java Implementation bubble sort