Click here to Skip to main content
14,426,540 members
   

Java

 
GeneralRe: Help with a website written in Java Pin
Gerry Schmitz28-Nov-19 6:37
mveGerry Schmitz28-Nov-19 6:37 
QuestionMessage Closed Pin
24-Nov-19 7:42
Memberravens game24-Nov-19 7:42 
QuestionHelp With Sorting Multidimensional String Array Pin
eskomo8424-Nov-19 7:15
Membereskomo8424-Nov-19 7:15 
AnswerRe: Help With Sorting Multidimensional String Array Pin
Richard MacCutchan24-Nov-19 7:23
communityengineerRichard MacCutchan24-Nov-19 7:23 
GeneralRe: Help With Sorting Multidimensional String Array Pin
eskomo8424-Nov-19 7:45
Membereskomo8424-Nov-19 7:45 
GeneralRe: Help With Sorting Multidimensional String Array Pin
Richard MacCutchan24-Nov-19 7:52
communityengineerRichard MacCutchan24-Nov-19 7:52 
GeneralRe: Help With Sorting Multidimensional String Array Pin
eskomo8424-Nov-19 10:09
Membereskomo8424-Nov-19 10:09 
GeneralRe: Help With Sorting Multidimensional String Array Pin
Richard MacCutchan25-Nov-19 0:14
communityengineerRichard MacCutchan25-Nov-19 0:14 
My apologies also, i misunderstood the question. The issue is that you need to compare the surnames of each entry, and swap the two entries if the first one is greater than the second. This means swapping all three items in the array entry. The following code should do it.
void sortContact(String[][] contactsArray, int numContacts) {
    String[] temp = new String[3];
    boolean changes;
    do {
        // we need to repeat this until no changes are made
        changes = false;
        
        // make sure we iterate through all contacts
        for(int i = 0; i < numContacts; i++) {

            // iterate through all the rest
            for(int j = i + 1; j < numContacts; j++) {

                // compare the two surnames
                if(contactsArray[i][1].compareTo(contactsArray[j][1]) > 0) {

                    // if the first surname is greater than the second, then swap them over
                    temp[0] = contactsArray[i][0];
                    temp[1] = contactsArray[i][1];
                    temp[2] = contactsArray[i][2];
                    contactsArray[i][0] = contactsArray[j][0];
                    contactsArray[i][1] = contactsArray[j][1];
                    contactsArray[i][2] = contactsArray[j][2];
                    contactsArray[j][0] = temp[0];
                    contactsArray[j][1] = temp[1];
                    contactsArray[j][2] = temp[2];

                    // keep going until there are no changes made
                    changes = true;
                }
            }
        }
    } while (changes == true);
}

QuestionJavaFX Background not beeing used on a ScrollPane element [Solved] Pin
Valentinor24-Nov-19 5:48
MemberValentinor24-Nov-19 5:48 
AnswerSolution Pin
Valentinor27-Nov-19 7:40
MemberValentinor27-Nov-19 7:40 
QuestionMessage Closed Pin
22-Nov-19 22:40
MemberMember 1466552522-Nov-19 22:40 
Question!!Please Help!! Student Needs Help It Shows me exercise/ wrong catagory moved to web dev JS Pin
Member 1465076510-Nov-19 7:04
MemberMember 1465076510-Nov-19 7:04 
QuestionRe: !!Please Help!! Student Needs Help It Shows me exercise 2 is correct but exercise 1 is not defined Pin
Richard MacCutchan10-Nov-19 7:24
communityengineerRichard MacCutchan10-Nov-19 7:24 
AnswerRe: !!Please Help!! Student Needs Help It Shows me exercise 2 is correct but exercise 1 is not defined Pin
Member 1465076510-Nov-19 12:15
MemberMember 1465076510-Nov-19 12:15 
AnswerRe: !!Please Help!! Student Needs Help It Shows me exercise 2 is correct but exercise 1 is not defined Pin
Member 1465076510-Nov-19 13:03
MemberMember 1465076510-Nov-19 13:03 
QuestionGlobal Histogram Implementation in Java Pin
Member 146130164-Oct-19 12:37
MemberMember 146130164-Oct-19 12:37 
AnswerRe: Global Histogram Implementation in Java Pin
phil.o4-Oct-19 23:06
mvephil.o4-Oct-19 23:06 
QuestionBiometric attendace machine data Pin
Member 146125164-Oct-19 2:15
MemberMember 146125164-Oct-19 2:15 
AnswerRe: Biometric attendace machine data Pin
Richard MacCutchan4-Oct-19 4:19
communityengineerRichard MacCutchan4-Oct-19 4:19 
AnswerRe: Biometric attendace machine data Pin
Gerry Schmitz4-Oct-19 7:35
mveGerry Schmitz4-Oct-19 7:35 
QuestionNeed to develop a program on Java for desktop Pin
Ryder Weber1-Oct-19 4:32
MemberRyder Weber1-Oct-19 4:32 
AnswerRe: Need to develop a program on Java for desktop Pin
Richard MacCutchan1-Oct-19 5:13
communityengineerRichard MacCutchan1-Oct-19 5:13 
AnswerMessage Closed Pin
1-Oct-19 6:44
MemberWishe19911-Oct-19 6:44 
AnswerRe: Need to develop a program on Java for desktop Pin
Gerry Schmitz4-Oct-19 21:35
mveGerry Schmitz4-Oct-19 21:35 
AnswerMessage Closed Pin
3-Nov-19 21:11
Memberseemasinghh3-Nov-19 21:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.