Question: I am checking if a String `"nitin"` is a palindrome but it's returning false. 

Please anyone help me to shorout this. 

```
public static void main(String[] args) {
    StringBuffer sb = new StringBuffer("nitin");
    sb.reverse();
    String rev = sb.toString();

    System.out.println(sb);
    System.out.println(rev);

    if (sb.equals(rev)) {
        System.out.println("true");
    } else {
        System.out.println("false");
    }
}

```

Answer: 
You are comparing the StringBuffer with the String.
Try with `if (sb.toString().equals(rev)) {`
You might misunderstand the StringBuffer and String. Your code might need to change

```
    StringBuffer sb=new StringBuffer("nitin");
    String before = sb.toString();
    sb.reverse();
    String after = sb.toString();
    System.out.println(before);
    System.out.println(after);
    System.out.println(before == after);
    if(before.equals(after)){
        System.out.println("true");
    }else{
        System.out.println("false");
    }

```