Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class namesAndNumbers {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- //inputs
- String names[] = {"Stanley Tucci", "Rosie Wild", "Jim Parsons", "Violet Canes", "Sterling Sunk", "Britt Ekland", "Robert Cool", "Kate Coquil", "George Long", "Dyan Cannon"};
- String phoneNumbers[] = {"1912 2814", "6575 9988", "7598 1234", "8790 0011", "0404 6482", "2034 1942", "1996 0002", "1998 4001", "1111 4578", "1978 0008"};
- String temp;
- for(int i=0; i<names.length; i++)
- {
- for(int j=1; j<names.length-i;j++)
- {
- if(names[j-1].compareTo(names[j])>0)
- {
- temp = names[j-1];
- names[j-1] = names[j];
- names[j] = temp;
- temp = phoneNumbers[j-1];
- phoneNumbers[j-1] = phoneNumbers[j];
- phoneNumbers[j] = temp;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement