Question: I'm trying to compare a string and a character (after converting it to a string). The code is not working like I expect it to work.

```
package main;
import java.lang.Character;

public class Main {
    public static void main(String[] args) {
        char myChar = 'a';
        String myString = "a";
        if(myString == Character.toString(myChar)) {
            System.out.println("This SHOULD work! But it doesn't.");
        } else {
            System.out.println("This SHOULDN'T work! But it does.");
        }
    }
}

```

What am I doing wrong here?

Answer: 
Use:

```
if(myString.equals(Character.toString(myChar)))

```

instead of:

```
if(myString == Character.toString(myChar))

```

---

`==` tests whether the two references pointing to the same object in the memory or not, while `equals` method checks if the two references pointing to the same object **OR** they have the same contents.
General rule for string comparison:

* `==` compares references (some sort of pointers if you are coming from C)
* `equals` compares the content.

In your case, you are comparing two different references to two different objects and that's why it is returning `false` where you expect it to be `true`.
For string comparison, always use the `String.equals()` method