This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Multi-Dimensional Array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Multi-Dimensional Array" Watch "Multi-Dimensional Array" New topic

Multi-Dimensional Array

L Tran

Joined: Jun 06, 2012
Posts: 7
I have an array, called, "myArray". Inside this myArray are 4 more arrays, "m0, m1, m2, m3".
How do I access all the elements in all the array?

Here's my code, :

This code only give me the first 2 elements in each array.
But, I would like to get all the elements in all the arrays.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60741

Think about this expression for a few minutes: ("m"+i).length;

What is it that you think it is going to give you?

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15376
Why don't you actually make a 2D array instead of using variables?

The reason why your code fails is you can not build a magical string and expect it to become a variable!

Run this in firebug:

Again, it is better to define it as one array, not multiple variables

I agree. Here's the link:
subject: Multi-Dimensional Array
Similar Threads
data from Child window to parent window
Access Data from Database By Submitting The select Values
MultiDimenaional Array sort
JSP variable typical problem