Simple sort program wont work
Hi, i have to make a program to accept 15 numbers from a user into an array, then sort them in ascending order and print them.
I know how to code it, but for some reason after i compile and try to run this in BlueJ, it shows the program is being executed(Work indicator turns red), but nothing happens.
Ive re-written it several times, but no luck.
import java.io.*;
publicclass Worksheet5_2
{
publicvoid display()throws IOException
{
InputStreamReader isr =new InputStreamReader(System.in);
BufferedReader br =new BufferedReader(isr);
int arr[] =newint[15];
for (int i=0;i<arr.length;i++)
{
arr[i]=Integer.parseInt(br.readLine());
}
System.out.println("The numbers you entered are");
print(arr);
sort(arr);
System.out.println("\n Numbers in ascending order");
print(arr);
}
privatevoid sort(int arr[])
{
for (int i=0;i<arr.length-1;i++)
{
for (int j=i+1;j<arr.length;j++)
{
if (arr[i]>arr[j])
{
int temp = arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
}
privatevoid print(int arr[])
{
for (int i=0;i<arr.length;i++)
{
System.out.print(arr[i]+" ");
}
}
}
>

