Bubble Sort Program in Java

By: Editorial Staff | Last Updated: | In: Java Tutorial


In this tutorial, we will share a java program to sort the elements of an array using the bubble sort algorithm. Bubble sort algorithm is the simplest sorting algorithm.

In this program, we traversed the first element of the array to the last element. We compare the current element with the next element if the current element is greater than next element, then it swapped.

Bubble Sort Program in Java

Copy the below Java program and execute it with the help Java Compiler.

Program Output

Array Before Bubble Sort
3 60 35 2 45 320 5
Array After Bubble Sort
2 3 5 35 45 60 320


About: Editorial Staff

Editorial Staff at FreeWebMentor is a team of professional developers leads by Prem Tiwari


Tags: , , , , , ,