Easy Way to Learn Selection Sort in JAVA - Java2021 : Online Tutorials Hub

Java2021 : Online Tutorials Hub

JAVA | Advance Java | MySQL | Data Structure | Git | HTML | CSS | JS

Latest

Post Top Ad

Tuesday, June 30, 2020

Easy Way to Learn Selection Sort in JAVA

Program of Selection Sort in JAVA
public class SelectionSort {
    public static void main(String[] args) {
        int array[]={5,6,7,1,9,3,14,11,17,2,10};
        int minimum,temp=0;
        for(int i=0;i<array.length;i++){
            minimum=i;
            for (int j=i+1;j<array.length;j++){
                if(array[j]<array[minimum]){
                    minimum=j;
                }
            }
            temp=array[i];
            array[i]=array[minimum];
            array[minimum]=temp;
        }
        for (int i=0;i<array.length;i++){
            System.out.print(array[i]+" ");
        }
    }
}
Output : 





Click to next or Searching Programs
Start with your Choice
-Important Programs for Freshers

Learn Pattern Programs 
Click to learn Array Programs
Click to Learn MySQL 
for any complaint regarding my Blog please visit contact us page and write what problem you have?

No comments:

Pages