Java example- selection sort algorithm

Selection sort algorithm

This is the Java example code for a selection sort algorithm. If you are not sure about the process of the selection sort, i recommend you to visit this tutorial:

Algorithm and Data Structure  

public class SelectionSort {

public static void main(String[] args){
//unsorted array
int[] arr={23,2,4,56,80};
//sorted array using selection sort
//display the content of sorted array
int i;
for(i=0;i<arr.length;i++) System.out.println(arr[i]);


public static void selectsort(int[] dataset, int n){

int i,j;
  int min=i;
      if(dataset[j]<dataset[min]) min=j; //find min value
  //then swap it with the beginning item of the unsorted list
  int temp=dataset[min];




romam comment


can u solve this question?
....question is:1) The Car class has two attributes, which correspond to the description and the customer's name. The description and the customer's name are each represented as a string of text. The description is initialised in the constructor, by being assigned the value of the constructor's only parameter. The customer's name is assigned an empty string ("").

Each attribute has a corresponding accessor method and there is another method to set the customer's name to a new name. A display method will output (suitably annotated) the description and, if the customer's name is not an empty string, the customer's name too.

Doni comment


Great place for newbie

yogesh comment


Nice Example

ROhit khatri comment

 ROhit khatri

very nice example for beginers

java2novice comment


very nice. for more java examples visit site


This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.