This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
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

Help with "LoginProgram"??

 
Diego Pinate
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello I'm really new to java...
I'm trying to make a very simple "Login" program.
Here's my code:




The thing is, that if you type admin it doesn't work... It just go to the else part of the if statement... any advice?

[edit]Add code tags. CR[/edit]
[ September 30, 2008: Message edited by: Campbell Ritchie ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to use the equals() method when comparing strings :

Check this article on Strings.
 
Diego Pinate
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh! Thanks!!! that made my day XD heh I was frustrated heh! I'm really new to it. Thanks a lot!
 
Campbell Ritchie
Sheriff
Posts: 48409
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Diego Pinate: Welcome to JavaRanch

When you are posting code, can I draw your attention to the CODE button please; it makes your code much easier to read. I have altered your first post so you can see how much better it looks.

And everybody has that problem with == and equals() at some time.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic