Hi all
Thank you David for your good explanation of String Arrays which finally
enabled me to finish the homework. However, I am wondering if there is
a more condensed version to find and print the longest name. I can
imagine If-else-else if statements will not work too well when one has a
whole lot of names to compare.
// Print the longest name
if((lengthOfFirstNameOfPerson1>=lengthOfFirstNameOfPerson2)
&&
(lengthOfFirstNameOfPerson1>=lengthOfFirstNameOfPerson3)){
System.out.println(firstNameOfPerson1[0] + " has the longest
first name");
}
else if
((lengthOfFirstNameOfPerson2>=lengthOfFirstNameOfPerson1) &&
(lengthOfFirstNameOfPerson2>=lengthOfFirstNameOfPerson3)){
System.out.println(firstNameOfPerson2[0] + " has the longest
first name");
}
else {
System.out.println(firstNameOfPerson3[0] + " has the longest
first name");
}
}
}
Thanks
Rene Erwee
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---