Results 1 to 6 of 6

Thread: Trying equals with Map

  1. #1
    Join Date
    Dec 2009
    Posts
    204

    Trying equals with Map

    Hello,
    I want to do the following using Maps
    - If the value is empty finish ()
    - Otherwise if the value deb! = Null and value to finish! = (Null)
    -) Else (
    For the first line I can not get the evenness, I try equals, compareTo, contains and stupidly == "" but that does not work. I put the code so that you can see the types of each variable.
    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 d = interval.getJour();
    String tm ="";	    				}		
    			}
    	}
    Any more help on this will be highly appreciated. Right now I am stuck here with my code.

  2. #2
    Join Date
    Dec 2009
    Posts
    178

    Re: Trying equals with Map

    Hello,
    I am very new to java, but I found a code which I think is related to your topic. If you need you can try it out.
    Code:
        if(interval.getFinish().contains(Temp)){
    			    	System.out.System.out.println("nm:"K + +- Date of discharge:+ d);	
    			    }
    			    else if(d! =null Finn & &! =null){
    				System.out.System.out.println("nm:"K + +"- st"+ + d"End"+ finn);}
    			    else{
    				System.out.System.out.println("nm:"k + +"- Day of absence"+ Day)  ; 
    			   		}
    I have no idea what all this means but you can try.

  3. #3
    Join Date
    Nov 2009
    Posts
    583

    Re: Trying equals with Map

    Hello,
    You can try the following code
    Code:
    Public class Interval {
    	
    	private String st;
    
    	private String fns;
    	
    	private String dt;
    
    	Public String getFinish() {
    		return fns;
    	}
     
    	Public void setFinish(String fns) {
    		this.fns = Finish;
    	}
     
    	Public String Getst() {
    		return home;
    	}
     
    	Public void setStart(String home) {
    		this.home = Start;
    	}
    	
    	  Public String toString() {
    		  if(st! =null)
    		    return "(" + Home + ", " + + Finish ")" ;
    		  else
    			  return "("+ day +")";		  
    	  }
    	
    	Public String getJour() {
    		return day;
    	}
     
    	Public void setJour(String days) {
    		this.day = Day;
    	}	
    }

  4. #4
    Join Date
    Nov 2009
    Posts
    333

    Re: Trying equals with Map

    Hello,
    I think you can try the following.
    Code:
    Public void appelint(String nm, String dtb, String endt) throws ParseException {
    		ArrayList l = <interval> (ArrayList <interval>)map.get(nm);
    		if(l ==null){
    			l = new ArrayList <interval>();
    map.could(nm, l);			   		}
    		Interval j =new Interval() ;
    j.setStart(dtb);
    j.setFinish(endt);
    l.add(j);
    map.could(nm, l);

  5. #5
    Join Date
    Nov 2009
    Posts
    518

    Re: Trying equals with Map

    Hello,
    Try replacing the following code with your code.
    Code:
    System.out.System.out.println("finn is |"+ finn +"| And is temp |"temp + +"|");
    if(finn.equals(tmp)){
    System.out.System.out.println("nm:"K + +- Date of discharge:+ deb);	
    }
    else 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); 
    }

  6. #6
    Join Date
    Nov 2009
    Posts
    330

    Re: Trying equals with Map

    Hello,
    To see if the string is an empty string, the test is to
    Code:
    if ("".equals(finn)) {
    }
    (no need to create a variable temp)
    To determine if the finn string is null, the test is to
    Code:
    if (finn ==null) {
    }
    I hope this answers to your questions. If you need any help feel free to post back.

Similar Threads

  1. In Mafia wars Level 450 equals screwed
    By Dechen in forum Video Games
    Replies: 4
    Last Post: 13-02-2011, 07:36 PM
  2. Explain the difference between == & .equals methods in Java?
    By Harpreet Gaur in forum Software Development
    Replies: 5
    Last Post: 30-01-2010, 11:36 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,311,767.16955 seconds with 17 queries