Professional Documents
Culture Documents
http://www.javatpoint.com/selection-sort-in-java
Submit
Submit
Search
Search on javatpoint...
Home
C++
C#
Java
Servlet
JSP
EJB
Struts2
Hibernate
Spring
Android
Design P
Quiz
Projects
Interview Q
Comment
Forum
Training
We can create a java program to sort array elements using selection sort. In selection sort algorithm,
we search for the lowest element and arrange it to the proper location. We swap the current
element with the next lowest number.
int index = i;
arr[index] = arr[i];
arr[i] = smallerNumber;
for(int i:arr1){
System.out.print(i+" ");
System.out.println();
for(int i:arr1){
System.out.print(i+" ");
Output:
prev
next
Latest 4 Tutorials
CouchDB
Docker
Rails
RichFaces