This code is the implementation of the bubble sort algorithm.
public class BubbleSortExp {
public static void main(String[] args) {
int s[] = { 23, 12, 466, 22, 1 };
int temp;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4 - i; j++) {
if (s[j + 1] < s[j]) {
temp = s[j + 1];
s[j + 1] = s[j];
s[j] = temp;
}
}
}
System.out.println("Sorted Array");
for (int i = 0; i < s.length; i++) {
System.out.println(s[i]);
}
System.out.println(s);
}
}