Send a suggestion!

We're building a brand new version of the site, and we'd love to hear your ideas

Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

How to sorts the names in alphabetical order in an array

Last post 05-13-2008 6:34 AM by mohamed_salafi84. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 05-13-2008 6:34 AM

    How to sorts the names in alphabetical order in an array

    Hi, i have 2 arrays the frist is to stroe students names and the second is for students grades i want to sort the names in alphabetical order and the grades moves to its names how to do this

    import java.util.*;
    public class Main {
    static Scanner console= new Scanner(System.in);
        public static void main(String[] args)
        {
       String []names=new String[10];   
       for(int i =0;i<names.length;i++)
       {
        System.out.print("Please Enter Student name ");
        System.out.println();
        names[i] =console.next();
        }  
        int []grade=new int[10];   
       for(int i =0;i<grade.length;i++)
       {
        System.out.print("Please Enter Student name ");
        System.out.println();
        grade[i] =console.nextInt();
        }
        
      }
    // Now I want to define a method that sort the names
    // and then moves the grade to its name   
    }
    • Post Points: 5
Page 1 of 1 (1 items)