• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to create Java 3D Array Object ?

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have 3 separate objects. like GSMTable,SMSTable,GPRSTable.
Those are include 2 fields called srDate,numberOfSR.
now i need to get them to 3D array object because i need to return it for my jqPlot line chart
this is my requirement

[[gsmTable.srDate][gsmTable.noOfSR],[smsTable.srDate][smsTable.noOfSR],[gprsTable.srDate][gprsTable.noOfSR]]


i wrote my own code like below.but i'm unable to complete it.

 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there an association between 1 GMSTable, 1 SMSTable, and 1 GPRSTable? If so, then you don't want a 3D array. You want to define a class that has those 3 fields as member variables.
 
priyanka kulathilaka
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeff Verdegan wrote:Is there an association between 1 GMSTable, 1 SMSTable, and 1 GPRSTable? If so, then you don't want a 3D array. You want to define a class that has those 3 fields as member variables.



thanks for the comment.but those are not a associated objects.
then how to get that array ?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What type of object will be stored at:

[0][0][0]
[0][0][1]
[0][1][0]
[1][0][1]
[1][1][1]

?

It's really not clear to me what the dimensions of your array represent, or how the various XyzTable classes relate to it.
 
priyanka kulathilaka
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeff Verdegan wrote:What type of object will be stored at:

[0][0][0]
[0][0][1]
[0][1][0]
[1][0][1]
[1][1][1]

?

It's really not clear to me what the dimensions of your array represent, or how the various XyzTable classes relate to it.




my gsmArray=[[2012-11-05,05],[2012-11-06,08],[2012-11-07,10],[2012-11-08,14],[2012-11-08,09]]
my smsArray=[[2012-11-05,02],[2012-11-06,03],[2012-11-07,04],[2012-11-08,04],[2012-11-08,03]]
my gprsArray=[[2012-11-05,04],[2012-11-06,07],[2012-11-07,08],[2012-11-08,04],[2012-11-08,07]]

I need to merge gsmArray,smsArray,gprsArray as 3D Array
then my expect array should be

[[2012-11-05,05],[2012-11-06,08],[2012-11-07,10],[2012-11-08,14],[2012-11-08,09],[2012-11-05,02],[2012-11-06,03],[2012-11-07,04],[2012-11-08,04],[2012-11-08,03],[2012-11-05,04],[2012-11-06,07],[2012-11-07,08],[2012-11-08,04],[2012-11-08,07]]
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

priyanka kulathilaka wrote:
my gsmArray=[[2012-11-05,05],[2012-11-06,08],[2012-11-07,10],[2012-11-08,14],[2012-11-08,09]]
my smsArray=[[2012-11-05,02],[2012-11-06,03],[2012-11-07,04],[2012-11-08,04],[2012-11-08,03]]
my gprsArray=[[2012-11-05,04],[2012-11-06,07],[2012-11-07,08],[2012-11-08,04],[2012-11-08,07]]



It looks like you need to learn to use classes and objects.

If one element of an xyzArray is itself an array with, what I assume is a Date and an Integer, then you should instead define a class that contains a Date and Integer (or Date and int, or whatever those values are), and name that class something meaningful and descriptive. Then the xyzArrays would be 1D arrays with each element being an object of that class you define.


I need to merge gsmArray,smsArray,gprsArray as 3D Array
then my expect array should be

[[2012-11-05,05],[2012-11-06,08],[2012-11-07,10],[2012-11-08,14],[2012-11-08,09],[2012-11-05,02],[2012-11-06,03],[2012-11-07,04],[2012-11-08,04],[2012-11-08,03],[2012-11-05,04],[2012-11-06,07],[2012-11-07,08],[2012-11-08,04],[2012-11-08,07]]



That doesn't look like a 3D array. That looks like a 2D array that's just a concatenation of your other 2D arrays.

You haven't described what the values represent or how the relate to each other, and your examples are not consistent with what you say you want, so I don't know how to help you any further.
 
I was born with webbed fish toes. This tiny ad is my only friend:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic