wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark ""String" = "String" = False...?" Watch ""String" = "String" = False...?" New topic
Author

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

Justin Porter
Ranch Hand

Joined: Nov 20, 2004
Posts: 34
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!


Want a free iPod, digital camera, or $300 cash? Completely legit offer at <a href="http://www.geocities.com/pricklymustard/freestuff.html" target="_blank" rel="nofollow">http://www.geocities.com/pricklymustard/freestuff.html</a> . I am looking for referrals which is why I need YOU!
Hung Yee
Greenhorn

Joined: Dec 22, 2004
Posts: 18
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

Joined: Nov 20, 2004
Posts: 34
Thanks bunches, definitely helped! :-)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: "String" = "String" = False...?