Evaluating substring does not work (now with better formatted code)

Hey everyone,

I have recently started using Processing and I love it! I do not have so much programming background, so I would be happy if you could help me from time to time :)

Right now, I have this code, which does not work as expected:

String varText = "012345";
String varSubstring = varText.substring(2, 3);
println(varSubstring); // This prints 2. So far, so good, but
// ... this does never evaluate to TRUE:
if (varSubstring == "2") {
  println("It is 2!");
} else {
  println("Oh no, it did not work!");
}

Does anyone have an idea how I could make this work?

Thank you very much!

Sebastian

Answers

Sign In or Register to comment.