Possible Duplicate:
How do I compare strings in Java?
java == vs equals() confusion
So, I am trying to develop an application that opens a JDialog at a time I enter. It only needs t be accurate to a second.
public void run() {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
timeset = "16:37";
while(true){
System.out.println("thread sleep");
try{Thread.currentThread().sleep(1000);}catch(InterruptedException ie){}
Calendar cal = Calendar.getInstance();
cal.getTime();
temptime = sdf.format(cal.getTime());
System.out.println("realtime = " + realtime);
System.out.println("timeset = " + timeset);
if(realtime == timeset){
System.out.println("if statement activated");
Alert.man();
break;
}
So, my problem is when I run the programme the if statement doesn't run when timeset and realtime are equal and I just can't figure it out. What's the deal?