A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Java
»
Java in General
Author
Representing in a collection
Dalia Sultana
Ranch Hand
Joined: Jul 16, 2006
Posts: 42
posted
Mar 09, 2007 07:35:00
0
I have some data in a flat file like the following :
date1 date2 date3
id1 10 12 13
id2 11 12 9
id3 7 9 4
I need to store this in a way so that a value can be easily retrieved by calling something like get(id1,date3), which should return 13.
I am currently thinking off something like this
Hashmap<int,
HashMap
<Date, value>>
But just wondering if there is an easier/better approach to do this?
Kudret Serin
Ranch Hand
Joined: Aug 02, 2005
Posts: 165
I like...
posted
Mar 09, 2007 08:17:00
0
You can define your own "data type".
For example:
class myData{ private int id; private String date1; private String date2; .... public int getId(){ return this.id; } public void getId(int id){ this.id=id; } ... // getter and setter methods for all fields. }
You can also provide a constructor with parameters to set the fields while instantiating an object.
I agree. Here's the link:
http://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: Representing in a collection
Similar Threads
creating a hashmap of hashmap using xml
converting sql union query into java
Logic iterate
composite-id Query
Hashtable and iterate
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter