Results 1 to 6 of 6

Thread: Fetching information from map

  1. #1
    Join Date
    Dec 2009
    Posts
    263

    Fetching information from map

    Hello,
    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. #2
    Join Date
    Dec 2009
    Posts
    292

    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() );
    I think you have not explained your code very well. Please explain in more details what exactly do you want to do.

  3. #3
    Join Date
    Nov 2009
    Posts
    347

    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. #4
    Join Date
    Dec 2009
    Posts
    263

    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);							
    		}
    Any help on this will highly appreciated. Thanks in advance.

  5. #5
    Join Date
    Nov 2009
    Posts
    343

    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. #6
    Join Date
    Dec 2009
    Posts
    263

    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)  ; 
    			   }
    			}		
    		}
    	}

Similar Threads

  1. Want information about MBA in Information Technology
    By Shantanu12 in forum Education Career and Job Discussions
    Replies: 12
    Last Post: 04-05-2012, 12:30 PM
  2. getting Error Fetching File in Opera mini
    By chuck28 in forum Technology & Internet
    Replies: 3
    Last Post: 17-09-2011, 09:59 PM
  3. Replies: 5
    Last Post: 08-04-2011, 10:36 AM
  4. Fetching Gmail on Windows Mobile 6.5
    By Rivan in forum Portable Devices
    Replies: 6
    Last Post: 09-06-2010, 03:58 AM
  5. Replies: 3
    Last Post: 03-02-2009, 09:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •