Java program to sort list of elements in ascending and descending order and show the exception handling
{
{
int a[] = new int[5];
try
{
for (int i = 0; i < 5; i++)
for (int i = 0; i < 5; i++)
bubbleSort (a, 5);
for (int i = 0; i < 5; i++)
for (int i = 4; i >= 0; i--)
{
{
}} private static void bubbleSort (int[]arr, int length)
{
int temp, i, j;
for (i = 0; i < length - 1; i++)
{
for (j = 0; j < length - 1 - i; j++)
{
if (arr[j] > arr[j 1])
{
temp = arr[j];
arr[j] = arr[j 1];
arr[j 1] = temp;
}
}
}
}
}
Java program to sort list of elements in ascending and descending order and show the exception handling
Reviewed by
on
September 05, 2019
Rating:
No comments: