• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error in if-else Statement !  RSS feed

 
Saad Zahoor
Ranch Hand
Posts: 82
Android
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Question :: this program perfect with int .. whenever i put "example" which is = to name so it should print out the if block but it print out else block no matter what i type even the condition met >> Help


 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37507
552
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saud,
Welcome to CodeRanch!

In Java, we use equals() rather than == to compare Strings. Give it a try with:



 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!