Hello Victor,

Please look at the section where you are splitting the contents of the
Array. You are missing one minor detail there.

Thanks,
Gagan

On Thu, Jan 27, 2011 at 4:20 AM, victor bruno <vb...@hotmail.com> wrote:

>  Hi fellows! Hope everybody is doing great.
> I'm solving the java Array lab and this far wrote the following code:
>
> String[] namePerson1 = new String[2];
>         String[] namePerson2 = new String[2];
>         String[] namePerson3 = new String[2];
>         int i =0;
>
>
>         // creates a loop for the user to insert first name
>         for( i=0; i<namePerson1.length; i++){
>             namePerson1[i] = JOptionPane.showInputDialog
>                     ("Please Enter First and Last Name ");
>             break;
>         }
>
>             // For loop to insert second name
>         for ( i= 0; i< namePerson2.length; i++){
>             namePerson2[i]=JOptionPane.showInputDialog
>                     ("Please Enter 2nd First and Last Name ");
>             break;
>         }
>
>         for( i =0; i<namePerson3.length; i++){
>             namePerson3[i]=JOptionPane.showInputDialog
>                     (" Please Enter 3rd First and Last Name ");
>             break;
>         }
>
>         //obtain the first name in array using split method
>         String[] firstName1 = namePerson1[i].split("");
>         String[] firstName2 = namePerson2[i].split("");
>         String[] firstName3 = namePerson3[i].split("");
>
>         //get the lengths of first names using length method of String
> Class
>         int lengthOfName1 = firstName1[0].length();
>         int lengthOfName2 = firstName2[0].length();
>         int lengthOfName3 = firstName3[0].length();
>
>         // compare the length and returns the longest first name
>         //display the results
>
>
>         if((lengthOfName1 > lengthOfName2) && (lengthOfName1 >
> lengthOfName3))
>
>           System.out.println(" Longest first name entered is "
>                   + firstName1[0] );
>
>         else if((lengthOfName2 > lengthOfName1) &&(lengthOfName2 >
> lengthOfName3))
>             System.out.println(" Longest first name entered is "
>                     + firstName2[0]);
>
>         else if ((lengthOfName3 > lengthOfName1)&&(lengthOfName3 >
> lengthOfName2))
>             System.out.println(" Longest first name entered is "
>                     + firstName3[0]);
>         //else
>             //System.out.println("Maybe 2 or more names have the same
> length");
>  // last line
> System.out.println(firstName1);
>
>
> And it has no output.The last line I inserted just to test the code,as a
> result I got the following output: [Ljava.lang.String;@a0dcd9.
>
> What's wrong please?
> Thank you,
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>  --
> To post to this group, send email to
> javaprogrammingwithpassion@googlegroups.com
> To unsubscribe from this group, send email to
> javaprogrammingwithpassion+unsubscr...@googlegroups.com<javaprogrammingwithpassion%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/javaprogrammingwithpassion?hl=en

-- 
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