# Issues finding strings

**URL:** <https://discourse.processing.org/t/issues-finding-strings/26017>\
**Category:** Beginners\
**Created:** [December 7, 2020, 3:14pm UTC](https://discourse.processing.org/t/issues-finding-strings/26017 "2020-12-07T15:14:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [December 7, 2020, 3:14pm UTC](https://discourse.processing.org/t/issues-finding-strings/26017/1 "2020-12-07T15:14:05Z")

</div>

Hi!  
I have some issues with the split() command and == “xyz”. I am currently creating a console like program, in which you can type “draw ellipse x y r1 r2”. However whenever I use `String segments[] = split(command,' ');` it prints that the `segments[0] = "draw"` however when I use `if(segments[0] == "draw" {}` it says it is not the same.

```auto
String com = "draw circle";

void setup() {
  
}

void draw() {
  
}

void mousePressed() {
  execute(com);
}

void execute(String command) {
  String segments[] = split(command," ");
  //println(segments[0],"draw");
  //String comNew = "";
  //for(int i = 0; i < segments[0].length(); i++) {
  // comNew += segments[0].charAt(i);
  //}
  
  if(segments[0] == "draw") {
    println("aaaaaaaaaaaaaa");
  }
}

```

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [December 7, 2020, 3:35pm UTC](https://discourse.processing.org/t/issues-finding-strings/26017/2 "2020-12-07T15:35:02Z")

</div>

> [@CodeMasterX](#):
>
> … however when I use `if(segments[0] == "draw" {}` it says it is not the same.

> **[equals() / Reference](https://processing.org/reference/String_equals_.html)**
>
> Compares two strings to see if they are the same. This method is necessary because it's not possible to compare strings using the equality operator (==). Returns true if the strings are the sam…

---

<div class="post-metadata">

**Author:** ![jay\_m](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jay_m/32/11020_2.png) [@jay\_m](https://discourse.processing.org/u/jay_m)\
**Post date:** [December 7, 2020, 4:16pm UTC](https://discourse.processing.org/t/issues-finding-strings/26017/3 "2020-12-07T16:16:35Z")

</div>

In Java Strings, the `==` operator is used to check a match of the _reference_ of both the string instances whereas `equals()` method used to check if the _content_ of the strings match.

```auto
  if (segments[0].equals("draw")) println("I found draw");
  else println("I did not find draw");

```
