Write a java program to accept 5 numbers using command line arguments sort and display them.
import java.io.*;
import java.util.*;
class cldemo
{
public static void main(String args[])
{
int[] a=new int[args.length];
for(int i=0;i<args.length;i++)
{
a[i]=Integer.parseInt(args[i]);
}
System.out.println("Elements we accepted are");
for(int i=0;i<args.length;i++)
{
System.out.print(a[i]+" ");
}
Arrays.sort(a);
System.out.println("\n Elemets in sorted order are");
for(int i=0;i<args.length;i++)
{
System.out.print(a[i]+ " ");
}
}
}
0 Comments