# Does a Table change a String format? (String equality)

**URL:** <https://discourse.processing.org/t/does-a-table-change-a-string-format-string-equality/31439>\
**Category:** Beginners\
**Created:** [July 25, 2021, 3:41pm UTC](https://discourse.processing.org/t/does-a-table-change-a-string-format-string-equality/31439 "2021-07-25T15:41:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dtools22](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@dtools22](https://discourse.processing.org/u/dtools22)\
**Post date:** [July 25, 2021, 3:41pm UTC](https://discourse.processing.org/t/does-a-table-change-a-string-format-string-equality/31439/1 "2021-07-25T15:41:39Z")

</div>

Hello,

I am writing a program that calls for information to be pulled from a spread sheet (.csv format) and put into “tile” objects that exist in the program. The quick version of my question is that when I load a String into the program from the .csv file there is some formatting issue where the program does not recognize it as the String listed in the spread sheet. Is there something that happens to the format of a String when it’s extracted from a spread sheet? Thank you for the help, more specifics below.

The spread sheet has 4 columns, each one for a corresponding attribute to the `class Tile` object:

“Tile Number” which stores `int` values (the number of each tile in the array of tiles)  
“Roll Number” which stores `int` values  
“Resource” which stores `String` values  
“Robber” which stores `String` values

```auto
class Tile {
  int rollnum;
  String resource;
  color c;
}

```

The “Tile Number” and “Roll Number” information works as expected. The color attribute for each tile is set in the display() function based off of the resource string value. For example:

```auto
if (resource == "Sheep") {
      //light green
      c = color(0, 255, 0);
    }

```

When I load in the spread sheet, tile1.resource is set to the spreadsheet’s corresponding “Resource” row which in this instance stores the value “Sheep”. If I run

`println(tile1.resource)`

The command line prints “Sheep”.

However the color variable never gets set to the new color value. After doing a little digging I ran the following code as a check.

```auto
if (tile1.resource == "Sheep"){
    println("They are equal");
  }else{
    println("They are NOT equal");
  }

```

The command line prints “They are NOT equal”. So my question is, does something about the String change when it’s stored in a .csv file as opposed to say a .txt file?

As always, thank you for the help.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [July 25, 2021, 4:11pm UTC](https://discourse.processing.org/t/does-a-table-change-a-string-format-string-equality/31439/2 "2021-07-25T16:11:21Z")

</div>

Yeah you can’t really check string with ==

Instead use if(s1.equals (“Sheep”))

---

<div class="post-metadata">

**Author:** ![dtools22](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@dtools22](https://discourse.processing.org/u/dtools22)\
**Post date:** [July 25, 2021, 4:45pm UTC](https://discourse.processing.org/t/does-a-table-change-a-string-format-string-equality/31439/3 "2021-07-25T16:45:21Z")

</div>

I knew as soon as I posted this the answer was something like this. I just couldn’t quite place it. Thank you as always for the help!

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [July 26, 2021, 9:51am UTC](https://discourse.processing.org/t/does-a-table-change-a-string-format-string-equality/31439/4 "2021-07-26T09:51:45Z")

</div>

Hello,

@dtools22 Many have come across this one including me!

Adding some references to the topic for more context and details.

On the [Processing](https://processing.org/) website:

- Wiki \> Troubleshooting\>  
[Troubleshooting · processing/processing Wiki · GitHub](https://github.com/processing/processing/wiki/Troubleshooting#why-dont-these-strings-equal)
- Reference \> String  
[String \ Language (API) \ Processing 3+](https://processing.org/reference/String.html)
- Reference \> String \> equals()  
[String::equals() \ Language (API) \ Processing 3+](https://processing.org/reference/String_equals_.html)

Internet:

- [Difference between == and .equals() method in Java - GeeksforGeeks](https://www.geeksforgeeks.org/difference-equals-method-java/)
- There are many more…

I like the details!

`:)`
