Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Sort/Java/Selection Sort
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
public class SelectionSort {
public static void main(String args[]){
int array[] = {10, 20, 25, 63, 96, 57}; // declaration of array
int size = array.length;

for (int i = 0 ;i< size-1; i++){
int min = i;

for (int j = i+1; j<size; j++){
if (array[j] < array[min]){
min = j;
}
}
int temp = array[min];
array[min] = array[i];
array[i] = temp;
}

for (int i = 0 ;i< size; i++){
System.out.print(" "+array[i]); // prints the elements in sorted manner
}
}
}