Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

"String" = "String" = False...?

 
Justin Porter
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, I'm trying to check and see if two strings are equal or not in a particular function. Here is my code:

It always returns -1, even if the substring is exactly the same as 'name'. I proved this with a S.O.PL statement... so what am I doing wrong here? Any help wouldl be appreciated! Thanks!
 
Hung Yee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to use the 'equals()' method in the String class to test for string equality. See this tech tip article from Sun for more details about string equality:
http://java.sun.com/developer/JDCTechTips/2004/tt0504.html#2
 
Justin Porter
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks bunches, definitely helped! :-)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic