Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , , , , ,

Sponsored Links



Trying equals with Map

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 12-02-2010
Member
 
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.
Reply With Quote
  #2  
Old 12-02-2010
Member
 
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.
Reply With Quote
  #3  
Old 12-02-2010
Member
 
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;
	}	
}
Reply With Quote
  #4  
Old 12-02-2010
Member
 
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);
Reply With Quote
  #5  
Old 12-02-2010
Member
 
Join Date: Nov 2009
Posts: 520
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); 
}
Reply With Quote
  #6  
Old 12-02-2010
Member
 
Join Date: Nov 2009
Posts: 331
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Trying equals with Map"
Thread Thread Starter Forum Replies Last Post
In Mafia wars Level 450 equals screwed Dechen Video Games 4 13-02-2011 07:36 PM
Explain the difference between == & .equals methods in Java? Harpreet Gaur Software Development 5 30-01-2010 11:36 AM


All times are GMT +5.5. The time now is 11:22 AM.