package com.tutorial4u;
import java.util.Arrays;
public class ArraySort
{
public static void main(String[] args)
{
int a [] = {
101,9,18,4,30,20};
for (int i = 0; i<a.length; i++)
{
for (int j = 0; j<a.length; j++)
{
if (a[i] < a[j])
{
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.println("Sorted array
is :"+Arrays.toString(a));
}
}
Sorted array is :[4, 9, 18, 20, 30, 101]
No comments:
Post a Comment