Hi everyone.
I am doing with the 1036 exercise. Everything is Ok until the display name. I 
dont know how to print out the name which is the longest first name. For 
example: Danil Shin has the longest first name. I need your help. Thank you.
This is my code:
 
import javax.swing.*;
public class arrays {
     public static void main(String[] args){
      String[] names = {"","","",""};
      int max = 0;
      for (int i=0; i<names.length; i++){
         names[i] = JOptionPane.showInputDialog("Enter names with first name 
and last name");
         }
         String[] name1 = names[0].split(" ");
         String[] name2 = names[1].split(" ");
         String[] name3 = names[2].split(" ");
         String[] name4 = names[3].split(" ");
         int lengthOfName1 = name1[0].length();
         int lengthOfName2 = name2[0].length();
         int lengthOfName3 = name3[0].length();
         int lengthOfName4 = name4[0].length();
         int [] abc = {lengthOfName1,lengthOfName2,lengthOfName3,lengthOfName4};
         for (int j = 0; j<abc.length; j++)  {   if ((abc[j]>max) || j==0)
                                                              max = abc[j];
                                                           }
         JOptionPane.showMessageDialog(null,max);   <---- my problem is here
         }
}


      
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to javaprogrammingwithpassion@googlegroups.com
To unsubscribe from this group, send email to 
javaprogrammingwithpassion-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to