Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to create 2-dimensional array

 
Prashant Langade
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you really sure you want an array? So far it looks like a map.
 
Sean Clark
Rancher
Posts: 377
Android Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Prashant Langade
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 377
Android Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am thinking you want an object that holds arrays.



Eric
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, sure, when *you* suggest it :p

:D
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic