aspose file tools
The moose likes Beginning Java and the fly likes String.equals() not giving desired proper result Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String.equals() not giving desired proper result" Watch "String.equals() not giving desired proper result" New topic
Author

String.equals() not giving desired proper result

Singh Anisha
Ranch Hand

Joined: May 09, 2012
Posts: 100



I am trying this code to send sms to user from my site it gives me response as result "Message+Sent+Successfully".
I am trying to check this response with matching substring but it always giving a false i.e "Try it again".
I am unable to find a clue why so??
substring subDisplayMsg is fetching proper substring"Successfully" then what is problem..
Please help me
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42956
    
  73
Print out the length of both strings, and then print them out character by character.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 43282
    
  32
There is a method in the String class something like endsWith(). Maybe that will provide what you want.
Krishna Kanth
Ranch Hand

Joined: Oct 23, 2006
Posts: 49
    
    1

Nothing wrong with your code. only possibility is your assumption on display msg. may be the response is in lowercase? try equalsIgnoreCase

I just tried below code and it printed "Message has been sent" for me.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 43282
    
  32
Welcome to the Ranch krishna kanth
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: String.equals() not giving desired proper result
 
It's not a secret anymore!