File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String.equals() not giving desired proper result

 
Singh Anisha
Ranch Hand
Posts: 100
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Print out the length of both strings, and then print them out character by character.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a method in the String class something like endsWith(). Maybe that will provide what you want.
 
Krishna Kanth
Ranch Hand
Posts: 49
1
Chrome Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47229
52
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch krishna kanth
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic