Hi....
I've wrote a code about arrange the names in descending order. But, I'm not sure it's right or wrong. Can u help me, please?
The code is:
import javax.swing.JOptionPane;
public class Names
{
public static void main(String[] argus){
int i = 0;
int n =10 ;
int j;
String temp;
String[] names = new String[10];
for ( i =0 ; i < names.length ; i++)
{
names[i] = JOptionPane.showInputDialog( null, " Enter the Name number " + (i+1));
}
System.out.println("Array content before sorting ");
for ( i = 0; i < names.length ; i++)
System.out.println( names[i] +" ");
for ( i = names.length-1 ; i =>0 ; i--)
for (j = 0; j < i ; j++)
if( names[j] < names[j+1] )
{
temp = names[j];
names[j+1] = names[j];
names[j+1] = temp;
}
}
}
I'll wait for u...