aspose file tools*
The moose likes Java in General and the fly likes How to create Java 3D Array Object ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to create Java 3D Array Object ?" Watch "How to create Java 3D Array Object ?" New topic
Author

How to create Java 3D Array Object ?

priyanka kulathilaka
Ranch Hand

Joined: Apr 13, 2011
Posts: 36
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.



Priyanka Kulathilaka
Software Engineer - Java
Sri Lanka
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

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

Joined: Apr 13, 2011
Posts: 36
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

Joined: Jan 03, 2004
Posts: 6109
    
    6

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

Joined: Apr 13, 2011
Posts: 36
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

Joined: Jan 03, 2004
Posts: 6109
    
    6

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 agree. Here's the link: http://aspose.com/file-tools
 
subject: How to create Java 3D Array Object ?