View Single Post
  #1 (permalink)  
Old 05-13-2008, 07:38 AM
masaka masaka is offline
Member
 
Join Date: Mar 2008
Posts: 31
masaka is on a distinguished road
How to sort 2 arrays together
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
Code:
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 }
Reply With Quote
Sponsored Links