DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Descending order for arrays by name

  1. #1
    Join Date
    Dec 2002
    Posts
    7

    Descending order for arrays by name

    Hi, thank you to all the people who previously helped me before....
    Is there a way to sort an array in decending order by name?

    I was trying to figure out what to do but this is what i have so far

    double [] Salary = new double [10];
    String [] Names = new String [10];
    int i, j;
    for ( i = 0; i < 10; i++)
    {

    System.out.print(" Name is: " + Names);
    Names = ReadInput.StringRead(); //asks user for Salry
    System.out.println(" Salary is: " + Salary );
    Salary = ReadInput.readDouble(); //asks user for Names

    }
    for (j=0; j < 10; j++)
    {
    System.out.println(Names[j] + ": " + Salary[j]);
    }

  2. #2
    Join Date
    Nov 2002
    Posts
    138
    you can use the sorting in the Collections class. as for your homework (on your other post), we had one like this the other semester. maybe my homework can get you started if i'm not too late. post your e-mail address and i'll send some stuff to you.

  3. #3
    Join Date
    Dec 2002
    Posts
    7

    email


  4. #4
    Join Date
    Dec 2002
    Posts
    7

    email


  5. #5
    Join Date
    Dec 2002
    Posts
    7

    is this right

    i was trying to compare it but i am not sure if this is right or not




    public Compare() {
    double [] Salary = new double [10];
    String [] Names = new String [10];
    String nameTemp = new String();
    double salaryTemp = 0.0;
    int i, j;
    for ( i = 0; i < 10; i++)
    {

    System.out.print(" Name is: " + Names[i]);
    Names[i] = ReadInput.StringRead(); //asks user for Salry
    System.out.println(" Salary is: " + Salary[i] );
    Salary[i] = ReadInput.readDouble(); //asks user for Names

    }
    for (j=0; j < 10; j++)
    {
    System.out.println(Names[j] + ": " + Salary[j]);


    //nameTemp = Names[i];
    //Names[i] = Names[j];
    //Names[j] = nameTemp;
    //salaryTemp = Salary[i];
    //Salary[i] = Salary[j];
    //Salary[j] = salaryTemp;
    //System.out.println(nameTemp + ": " salaryTemp );
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center