wood burning stoves 2.0*
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
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
Marshal

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

Joined: Oct 13, 2005
Posts: 40052
    
  28
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: 40052
    
  28
Welcome to the Ranch krishna kanth
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String.equals() not giving desired proper result