---
title: "Comment by Niraj Kumar Gangale on \"Strings in java explained\" | Hashnode"
description: "When we use the (==) operator java compares the value of the variables basically it checks whether the variables are pointing to the same object or different. N"
url: "https://hashnode.com/posts/strings-in-java-explained/6330607a3ac18d0d78a03786/comment/63341b6ffa20fa4bc8e516cb"
---

[Discussion](https://hashnode.com/posts/strings-in-java-explained/6330607a3ac18d0d78a03786)

Comment [Strings in java explained](https://hashnode.com/posts/strings-in-java-explained/6330607a3ac18d0d78a03786)

[Niraj Kumar Gangale](https://hashnode.com/@iamnirajdotcom)

[Sep 28, 2022](https://hashnode.com/posts/strings-in-java-explained/6330607a3ac18d0d78a03786/comment/63341b6ffa20fa4bc8e516cb)

When we use the (==) operator java compares the value of the variables basically it checks whether the variables **are pointing to the same object or different.**

No Akash the, Equal to (==) does not compare that variable is pointing to the same operator it just compares the value itself.

```
String firstString = "Bunny";
String secondString = "Bunny";
```

Both the firstString and secondString have equal values of the address i.e. a Hexadecimal value, but saying they **are pointing to the same object or different** means also the same.

[Akash Dev](https://hashnode.com/@Akash2310)

[Sep 28, 2022](https://hashnode.com/posts/strings-in-java-explained/6330607a3ac18d0d78a03786/comment/63341b6ffa20fa4bc8e516cb#reply-63345606e594fa4ba3b8a9a9)

Thanks for mentioning. Basically what I want to say is (==) doesn't check for equality of values. It only checks identity. Simply I can say that it compares the object references.
