Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Java in General and the fly likes Getting Elements from My Array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Getting Elements from My Array" Watch "Getting Elements from My Array" New topic
Author

Getting Elements from My Array

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
I have an two dimensional array with three elements for each item(4624 items), One array for each employee(26-40). These are date, hours, taskid. My goal is to have a report that shows 39 weeks from this week and show the amount of hours each employee has scheduled each week. My question is how to get the data from my array, grouping on week ending matching each of the 39 weeks in my report.

If I loop thru the 39 week periods then loop thru my array to find matching dates would this be the most effecient way?

By the way I had this working by using sql to feed data into an iseries file then getting data back out with sql etc. But this is way too much traffic on our server.
Eric Weinberg
Greenhorn

Joined: Nov 11, 2004
Posts: 18
Why are you using multi dimensional arrays to represent class data?

Why not create an Employee object that has 3 members, hours, date, taskid. You can then just have a regular ol 1-d array of Employees.
Nickolas Case
Ranch Hand

Joined: Apr 26, 2008
Posts: 98
Is it possible to use a hash? That way you could have a key(say date) that would contain all the values you are looking for. Looking through the API, it looks as though a hashtable would be your best bet.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Getting Elements from My Array
 
Similar Threads
Compiling SQL statement before execute
help with batch processing large number of db records
Toplink One Class From Two Seperate Table
Best Solution for Presenting Data
Dynamic Form Creation within a Loop