Below is a simple Java implementation (Source Code) of Bubble Sort Algorithm
/* From Techie.Click By JP */ public class BubbleSort { public static void main(String[] args) { int[] num = {3, 5, 8, 10, 2, 5, 7, 4}; int b=num.length-1; for(int bub=0; bub<num.length-1;bub++) { for(int i=0; i<b;i++) { if(num[i] > num[i+1]) { int temp=num[i+1]; num[i+1] = num[i]; num[i] = temp; } } b--; } for(int i=0; i<num.length; i++) { System.out.print(num[i] + " "); } System.out.print("\n"); } }
A simple Java implementation of Bubble Sort Algorithm (Source Code)
Leave a Reply