It's not a secret anymore!*
The moose likes HTML, CSS and JavaScript and the fly likes How to create 2-dimensional array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to create 2-dimensional array " Watch "How to create 2-dimensional array " New topic
Author

How to create 2-dimensional array

Prashant Langade
Ranch Hand

Joined: Jul 01, 2009
Posts: 71
Hi

I have a array which contains values as IA,FA,GA.

Now my requirement is this that i need to create two-dimensional array such that it should be

IA Investment Accounting
FA Fund Accounting
GA Gap Accounting

I am trying to do something like this


accountViewsArray is my array with values as FA,IA,GA.


Can any one please help me?
>
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Are you really sure you want an array? So far it looks like a map.
Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

Prashant Langade wrote:



Hey,

Does the 2nd 'for loop' not end up with you putting the same data into the row:
?

Might it be better to create a simple class that encorporates the 2 pieces of data and stores them in the array?

Sean


I love this place!
Prashant Langade
Ranch Hand

Joined: Jul 01, 2009
Posts: 71
Hi David and Sean,

Thanks for your reply.


Today 6:00:40 PM Subject: How to create 2-dimensional array

--------------------------------------------------------------------------------

Are you really sure you want an array? So far it looks like a map.


@David,it is a array which i am getting in a javascript function through a server response.

Might it be better to create a simple class that encorporates the 2 pieces of data and stores them in the array?


@Sean,Actually i am getting the response from the server through a ajax call in the string format like this (IA,FA,GA)(i.e comma separated) in the javascript function
Then after that, i am splitting that string and stroing that in a array.
Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

Hey,

In that case I wouldn't be manually setting those names from the ID's.
I would either be looking up the title (Investment Accounting, etc..) from a given ID (IA, etc...).
There are a number of ways that you could do this; from a database, from a properties file, you could even use an enum if it is unlikely to change or you can hardcode it with if statements etc.

I just personally don't think going with the array you have there is the best idea.

Sean
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
I am thinking you want an object that holds arrays.



Eric
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Oh, sure, when *you* suggest it :p

:D
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to create 2-dimensional array
 
Similar Threads
Question on array conversion
Question on multi dimensional array
Array conversion Question from Dan's test
Sub: Arrays
Array Conversion