-
-
Notifications
You must be signed in to change notification settings - Fork 176
Closed
Description
Issue description
When I tested the String comparison example given on the String reference page in Processing 3.3.6:
// Comparing String objects, see reference below.
String p = "potato";
if (p == "potato") {
println("p == potato, yep."); // This will not print
}
// The correct way to compare two Strings
if (p.equals("potato")) {
println("Yes, the contents of p and potato are the same.");
}
Both lines print due to String interning in Java.
URL(s) of affected page(s)
https://processing.org/reference/String.html
Proposed fix
Use a different example:
String a = "good";
String b = "bye";
String c = a + b;
println(c);
if (c == "goodbye") {
println("The == works");
}
if (c.equals("goodbye")) {
println("The .equals works");
}
Metadata
Metadata
Assignees
Labels
No labels