I wrote following program but i want to remove "," from last element, what should i do?Is there any in-build method?
public class arraySort
{
public static void main(String[] args)
{
int a[]={2,7,5,6,9,8,4,3,1};
for(int i=0;i<a.length;i++)
{
for(int j=i+1;j<a.length;j++)
{
if(a[i]<a[j])
{
int temp;
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
System.out.print("Descending order:{");
for(int i=0;i<a.length;i++)
{
System.out.print(a[i]+",");
}
System.out.println("}");
}
}
output:Descending order:{9,8,7,6,5,4,3,2,1,}