• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String.equals() not giving desired proper result

 
Singh Anisha
Ranch Hand
Posts: 100
Java
  • 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
Posts: 42968
73
  • 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: 49379
62
  • 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
  • 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: 49379
62
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch krishna kanth
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic