> 
> **Possible Duplicate:**  
> 
> [How do I compare strings in Java?](https://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java)  
> 
> [Java String.equals versus ==](https://stackoverflow.com/questions/767372/java-string-equals-versus) 
> 
> 
> 

I am new to Selenium and Java. 

I have tried the below to compare the field value of last name to the one which i supplied.

```
String lastname=selenium.getValue("//*[@id='lastName']");
System.out.println(lastname);
assertTrue (lastname == "xxx");

```

It is keep on failing.

Just literally tried to change the last line with help of Eclipse (just trial and error)

```
assertTrue("lastname.equals("xxx")); 

```

It is working fine... Why it is failed in first case? == is not allowed to compare strings?