|
It's easyer than it looks. Everything instead of the "String.split"
method is in the lessons preceding this homework. You can check how to
use this method in the "javadoc". Anyway, try to understand this code: public class OwnJavaArray { public static void main(String[] args) { String fullNames[]=new String[3]; for(int i=0;i<3;i++){ fullNames[i] = JOptionPane.showInputDialog(null,"Enter full name of person number " + (i+1)); } String[] Name1 = fullNames[0].split(" "); String[] Name2 = fullNames[1].split(" "); String[] Name3 = fullNames[2].split(" "); int length1=Name1[0].length(); int length2=Name2[0].length(); int length3=Name3[0].length(); int i=0; if ((length1>=length2)&(length1>=length3)){ i=0; } if ((length2>=length3)&(length2>=length1)){ i=1; } if ((length3>=length2)&(length3>=length1)){ i=2; } JOptionPane.showMessageDialog(null,"The family member with a longest first name is " + fullNames[i]); } } En/na Dasarathy Raghavan ha escrit: Please take a look at the class below.. it does not quite match the homework .. but you should be able to get the idea of what I was trying to do --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~--- |
begin:vcard fn:Josep Maria Sans n:Sans;Josep Maria org;quoted-printable:ADOS - Serveis d'electr=C3=B2nica adr;quoted-printable:;;P=C3=A7a. Everest vuitanta-cinc, 3;Taradell;Barcelona;08552;SPAIN email;internet:[EMAIL PROTECTED] tel;work:0034 93 880 12 89 tel;cell:0034 636 22 79 24 url:www.adoselectronica.com version:2.1 end:vcard
