It's not a secret anymore!
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
JavaRanch » Java Forums » Java » Java in General
Bookmark "Getting Elements from My Array" Watch "Getting Elements from My Array" New topic

Getting Elements from My Array

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1562
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

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.
I agree. Here's the link:
subject: Getting Elements from My Array
jQuery in Action, 3rd edition