-1

I have to work in processing for this project and I want to load strings and floats from a text file. In my SaveLoad() I check if the name of the first index == "Dot" but it comes back false. I wonder why because the print(name); I put in there prints Dot with no space on the beginning or end, so that is exactly the same right?

void SaveLoad()
{
    for (TableRow row : table.rows())
  {
  String name = (String) row.getString("name");
  print(name);
    if(name == "Dot")
    {
      print("1");
      treeCreator.treeDots.add(new TreeDot(int(row.getFloat("x")),int(row.getFloat("y")),int(row.getFloat("dotThickness")),int(row.getFloat("lR")),int(row.getFloat("split"))));
    }
    if(name == "BranchDot")
    {

    }
    if(name == "Leaves")
    {

    }
  }
}
anonymous-dev
  • 2,897
  • 9
  • 48
  • 112
  • 1
    possible duplicate of [How do I compare strings in Java?](http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java) – Orhan Obut Nov 28 '14 at 14:13

1 Answers1

0

You can't compare String using ==

https://processing.org/reference/String_equals_.html

do:

if(name.equals("BranchDot"))

v.k.
  • 2,826
  • 2
  • 20
  • 29