Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
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 Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark ""String" = "String" = False...?" Watch ""String" = "String" = False...?" New topic

"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="" target="_blank" rel="nofollow"></a> . I am looking for referrals which is why I need YOU!
Hung Yee

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:
Justin Porter
Ranch Hand

Joined: Nov 20, 2004
Posts: 34
Thanks bunches, definitely helped! :-)
Have you tried LearnNowOnline?
subject: "String" = "String" = False...?