if you want to compare two primitive types then you'll use == operator and for all other objects (String, vector, set etc) you'll use .equal.
.equal method compare the contents of the contained by the object. if you use == operator on two objects (say string) it'll compare the memory location not the string itself.
just look at the following code
in this case the if condition will work
now look at the following code .. and
test yourself
[code]
String a ="a";
String b = new String("a");
if (a==b){
System.out.println("the else statement will be printed, find out why");
}