Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: upcoming assignment in 2D arrays - for preparation, can someone describe the importance of a 2d array?

  1. #1
    Member
    Join Date
    Feb 2013
    Location
    earth
    Posts
    88
    Thanks
    12
    Thanked 9 Times in 9 Posts

    Default upcoming assignment in 2D arrays - for preparation, can someone describe the importance of a 2d array?

    .


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,145
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: upcoming assignment in 2D arrays - for preparation, can someone describe the importance of a 2d array?

    Arrays allow you to have one name for many values.
    Two dim arrays are usually considered as having rows and columns. Many spread sheet apps work with rows and columns. Many games use boards with rows and columns.
    Some apps map their data in x,y terms. The pixels in an image.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member
    Join Date
    Feb 2013
    Location
    earth
    Posts
    88
    Thanks
    12
    Thanked 9 Times in 9 Posts

    Default Re: upcoming assignment in 2D arrays - for preparation, can someone describe the importance of a 2d array?

    V

  4. #4
    Member
    Join Date
    Jan 2013
    Posts
    34
    My Mood
    Busy
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default Re: upcoming assignment in 2D arrays - for preparation, can someone describe the importance of a 2d array?

    Also for functionality, a for loop can be used to step through a 2d array, like this:

    for(Type[] arrayName : Type[][] otherArray){
    }

    I'm assuming you probably already know this, but just incase.

  5. The Following User Says Thank You to vividMario52 For This Useful Post:

    javaiscool (February 12th, 2013)

  6. #5
    Member
    Join Date
    Feb 2013
    Location
    earth
    Posts
    88
    Thanks
    12
    Thanked 9 Times in 9 Posts

    Default Re: upcoming assignment in 2D arrays - for preparation, can someone describe the importance of a 2d array?

    .

  7. #6
    Member
    Join Date
    Jan 2013
    Posts
    34
    My Mood
    Busy
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default Re: upcoming assignment in 2D arrays - for preparation, can someone describe the importance of a 2d array?

    Of course

    When we have
    for(int x : array)

    Its basically saying:
    Ok, loop through the array 'array', treating each element as x.

    So
    for(int x : array){
      x--;
    }
    would subtract 1 from every element in the array.
    Understand?
    Its basically the same for 2d arrays.

    for(int[] x : twoDArray){
      System.out.print(x.length);
    }

    The above code sample would print out the length of every row in the 2D array.

    Hpe I helped!

    - vividMario52

  8. The Following User Says Thank You to vividMario52 For This Useful Post:

    javaiscool (February 26th, 2013)

  9. #7
    Member
    Join Date
    Feb 2013
    Location
    earth
    Posts
    88
    Thanks
    12
    Thanked 9 Times in 9 Posts

    Default Re: upcoming assignment in 2D arrays - for preparation, can someone describe the importance of a 2d array?

    .

  10. #8
    Member
    Join Date
    Feb 2013
    Location
    earth
    Posts
    88
    Thanks
    12
    Thanked 9 Times in 9 Posts

    Default Re: upcoming assignment in 2D arrays - for preparation, can someone describe the importance of a 2d array?

    3

Similar Threads

  1. Introduction to programing class. I am stuck on my assignment arrays.
    By dozindave in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 18th, 2012, 10:31 PM
  2. Need help with a Java Assignment regarding enums and arrays
    By Kranti1992 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 12th, 2012, 07:49 AM
  3. [SOLVED] A little assignment involving arrays.
    By Melawe in forum What's Wrong With My Code?
    Replies: 39
    Last Post: May 1st, 2011, 10:43 PM
  4. [SOLVED] Java assignment, concerning Arrays and Loops
    By trejorchest in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 17th, 2011, 12:59 PM

Tags for this Thread