In this video, we will learn How to SORT an Array using Loops.
0:00 Introduction
0:26 Steps
0:45 Understanding all steps with Excel
28:28 Understanding all steps with Code
Here is the program:
public class Sort {
public static void main(String[] args) {
//step - 1 - initializing array
int[] arr = {5, 9, 8, 7, 6, 1, 2, 10, 100, 0};
// step 2 - Defining Loops
// outer loop
for (int i = 0; i LT arr.length; i++) {
// inner loop
for (int j = i+1; j LT arr.length; j++) {
// step - 3 - Comparing Elements
if(arr[i] GT arr[j]){
// step 4 - Swapping if required
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
} // step - 5 - Print element
System.out.print(arr[i]+" ");
}
}
}
En esta página del sitio puede ver el video en línea Java Basics - Session - 10 - How to SORT an Array using Loops (Bubble Sort) de Duración hora minuto segunda en buena calidad , que subió el usuario Khan's Tech Lab 13 julio 2025, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 52 veces y le gustó 2 a los espectadores. Disfruta viendo!