|
| ||||||||||
| Tags: database, information, map, programming language, tools, utilities |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Fetching information from map
I want to do operations on data contained in a MAP. For now I associate a key (which is the name of a person) several intervals containing two dates (that I created for a class with Interval Start and Finish I add in an ArrayList before putting in the map. I would now like to identify the start date and end date way to do operations on the latter (subtraction then cancels out dates in the interval to count the number of days). Any help on this will be highly appreciated. |
|
#2
| |||
| |||
| Re: Fetching information from map
Hello, I do not know what you are exactly asking about, but I know that to browse the list of values must be this, this can help you. Code: / / To browse the values
for (Iterator i = map.values().iterator() I.hasNext() ; ){
System.out.System.out.println( i.next() ); |
|
#3
| |||
| |||
| Re: Fetching information from map
Hello, You can try the following code, if it suits you well and good. Code: for (Iterator i = map.values().iterator() I.hasNext() ; ) {
/ / System.out.println (i.next ());
List inv = (List)i.next();
for (Iterator j = inv.iterator() J.hasNext() ; ) {
Interval intl = j.next();
Start = st intl.Getst();
Finish = intl end.getFinish();
}
} |
|
#4
| |||
| |||
| Re: Fetching information from map
Hello, I need the dates identified in the key function is the first element of comparison forth has continued. I tried a 'For' embracing what you told me but it did not. I also tried this way but I have not managed to do better than that, i.e do not split dates. Code: for(Iterator it = map.entrySet().iterator(); It.hasNext();) {
Map.Entry e = (Entry) it.next();
Object k = e.getKey();
Object v = e.getValue();
System.out.System.out.println("nm:"K + +"Xqsq"+ v);
} |
|
#5
| |||
| |||
| Re: Fetching information from map
Hello, I have a code with me, you can try it, here it is Code: void tmap(){
/ / ierator on the map
Iterator <Map.Entry<Couple <String> List>> i = map.entrySet().ierator();
while (i.hasNext()){
Map.Entry<Couple <String> List> peer = i.next();
/ / get the key
Couple couple = peers.getKey();
/ / displays the full name associated wih the pair
System.out.print(couple.getName() + " " + Couple.getpara() + " : ");
/ / get value
List list = <String> peers.getValue();
/ / display each iem in the list
for(int i =0; I <list.size(); I + +)
System.out.print(list.get(i) + " ");
System.out.System.out.println("");
}
} |
|
#6
| |||
| |||
| Re: Fetching information from map
Hello, Thanks for your replies guys, I have made some of the changes in my code. So, here is my modified and updated code. Have a look at it and if you find any mistakes, then please correct me. Code: Public void tmap(){
for(Iterator i = map.entrySet().ierator(); It.hasNext();) {
Entry e = (Entry) i.next();
Object k = e.getKey();
Object v = e.getValue();
for (Iterator j = ((AbstractList <GregorianCalendar>) v).ierator() J.hasNext() ; ) {
Interval interval = (Interval) j.next();
String interval = deb.Getstart();
String interval = finn.getFinish();
String day = interval.getJour();
if(deb! =null Finn & &! =null){
System.out.System.out.println("nm:"K + +"- Start"+ + deb"End"+ finn);}
else {
System.out.System.out.println("nm:"k + +"- Day of absence"+ Day) ;
}
}
}
} |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Fetching information from map" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Want information about MBA in Information Technology | Shantanu12 | Education Career and Job Discussions | 12 | 04-05-2012 12:30 PM |
| getting Error Fetching File in Opera mini | chuck28 | Technology & Internet | 3 | 17-09-2011 09:59 PM |
| Changing the OEM information on Computer System Information Screen | Ikhyd | Operating Systems | 5 | 08-04-2011 10:36 AM |
| Fetching Gmail on Windows Mobile 6.5 | Rivan | Portable Devices | 6 | 09-06-2010 03:58 AM |
| Fetching data from a database and display it in a view - Ruby on Rails | Sadashiva | Software Development | 3 | 03-02-2009 09:59 PM |