Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

comparing values from database and from a textbox

 
abhishek rathur
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The thing is its not going inside the give if loop,however all the 4 values str1,str2,val1,val2 are being printed correctly.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are comparing strings using "==" ?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And please UseCodeTags the next time you want to post some code.
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please try using: if ( val1.equals(str1)) instead of if ( val1==str1). The former will check for the similarity of the values but the latter will only check if both the variables point/refer to the same string.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohamed Sanaulla wrote:Please try using: if ( val1.equals(str1)) instead of if ( val1==str1). The former will check for the similarity of the values but the latter will only check if both the variables point/refer to the same string.

I wish the original poster would have figured that by himself...
 
abhishek rathur
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok ,i got that.Thank you Christophe Verré and Mohamed Sanaulla
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Christophe Verré wrote:
Mohamed Sanaulla wrote:Please try using: if ( val1.equals(str1)) instead of if ( val1==str1). The former will check for the similarity of the values but the latter will only check if both the variables point/refer to the same string.

I wish the original poster would have figured that by himself...


Yeah, my mistake. I realized after posting the reply
 
abhishek rathur
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its working.Actually i am creating a desktop application,i have create a login panel ,what i want is to navigate from this login panel to other panel.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic