We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
String equality (Read 978 times)
String equality
May 14th, 2005, 8:49pm
 
I don't seem to be able to get a very simple String equality to work as demonstrated in this simple bit of code:

String sent="This is a sentence.";
String[] word = split(sent);
for (int i=0;i<word.length;i++){
 if (word[i]=="is"){
   print(word[i]+" is word "+i);
 }
}
Re: String equality
Reply #1 - May 14th, 2005, 9:03pm
 
use String.equals("..") with strings:
Code:

String sent="This is a sentence.";
String[] word = split(sent);
for (int i=0;i<word.length;i++){
if (word[i].equals("is")){
print(word[i]+" is word "+i);
}
}


TomC explains:
http://processing.org/discourse/yabb/YaBB.cgi?action=display;board=Syntax;num=1100632237;start=0#4

F
Re: String equality
Reply #2 - May 15th, 2005, 4:48pm
 
also the final item in the faq under "common issues/not bugs"
http://processing.org/faq/bugs.html#issues
Page Index Toggle Pages: 1