This is my code:
String[] nameArrayForPerson1 = person1NameInstance.split(" ");
String[] nameArrayForPerson2 = person2NameInstance.split(" ");
// Get the lengths of strings using length() instance (non-static) method
int lengthOfFirstNameOfPerson1 = nameArrayForPerson1[0].length();
int lengthOfFirstNameOfPerson2 = nameArrayForPerson2[0].length();
nameArrayForPerson1 = JOptionPane.showInputDialog("Please enter your
name");
nameArrayForPerson2 = JOptionPane.showInputDialog("Please enter your
name");
// Compare the lengths of the first names between person1 and
person2
if (lengthOfFirstNameOfPerson1 > lengthOfFirstNameOfPerson2){
System.out.println(nameArrayForPerson1[0] +
" has longer first name than " +
nameArrayForPerson2[0]);
}
else
System.out.println(nameArrayForPerson2[0] +
" has longer first name than " +
nameArrayForPerson1[0]);
}
I am a little confused because nothing that I have tried is not worked
--
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