.
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.
.
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.
V
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.
javaiscool (February 12th, 2013)
.
Of course
When we have
for(int x : array)
Its basically saying:
Ok, loop through the array 'array', treating each element as x.
So
would subtract 1 from every element in the array.for(int x : array){ x--; }
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
javaiscool (February 26th, 2013)
.
3