Results 1 to 3 of 3
  1. #1
    akiraaisha is offline Member
    Join Date
    Aug 2014
    Posts
    3
    Rep Power
    0

    Exclamation Please help in my Array[] problem

    This is my code:

    Java Code:
    import static java.lang.System.out;
    public class Fibonacci
    {
        public static void main(String[] args)
        {
           String[][][] names = {
               {"Mr. ", "Mrs. ", "Ms. "},
               {"Smith", "Joe","Julian"},
               {"Lugod", "Jonas", "Smooth"}
            };
            out.println(names[0][1][0] + names[0][2][0]);
        }
    }
    I got an error at the "Mr. "
    PLease help

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,610
    Rep Power
    5

    Default Re: Please help in my Array[] problem

    You have declared a "3 dimensional array" but only initialized it to a "2-dimensional array."
    Note: The outer {} do not play a part in the dimension. They are simply required to encapsulate
    the elements. So your array contents are really just:
    Java Code:
     {"Mr. ", "Mrs. ", "Ms. "},{"Smith", "Joe","Julian"},{"Lugod", "Jonas", "Smooth"}
    Regards,
    Jim
    Last edited by jim829; 08-18-2014 at 03:55 PM.
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    akiraaisha is offline Member
    Join Date
    Aug 2014
    Posts
    3
    Rep Power
    0

    Default Re: Please help in my Array[] problem

    I just figured it out,
    out.println(names[0][0] + names[1][2] + names[2][0]);
    }
    }
    Output: Mr. Julian Lugod

Similar Threads

  1. Replies: 3
    Last Post: 12-28-2013, 09:39 PM
  2. Really need help with an Array problem
    By ndsmith20 in forum New To Java
    Replies: 4
    Last Post: 11-07-2012, 10:57 PM
  3. problem with array
    By adrian110288 in forum New To Java
    Replies: 2
    Last Post: 02-09-2012, 03:15 PM
  4. Replies: 0
    Last Post: 05-12-2011, 07:04 PM
  5. Array problem
    By c3jcarmy in forum New To Java
    Replies: 11
    Last Post: 03-11-2010, 02:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •