File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Help with Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help with "LoginProgram"??" Watch "Help with "LoginProgram"??" New topic

Help with "LoginProgram"??

Diego Pinate

Joined: Sep 29, 2008
Posts: 2
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é

Joined: Nov 24, 2005
Posts: 14688

You need to use the equals() method when comparing strings :

Check this article on Strings.

[My Blog]
All roads lead to JavaRanch
Diego Pinate

Joined: Sep 29, 2008
Posts: 2
Oh! Thanks!!! that made my day XD heh I was frustrated heh! I'm really new to it. Thanks a lot!
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46405
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.
I agree. Here's the link:
subject: Help with "LoginProgram"??
It's not a secret anymore!