User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 456,533 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,906 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 2973 | Replies: 2
Reply
Join Date: Aug 2004
Posts: 11
Reputation: srthomso is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
srthomso srthomso is offline Offline
Newbie Poster

code repeatedly 2 ask user 4 a password until correct (=Java) but cant c wots wrong.

  #1  
Aug 10th, 2004
here's the code:

string reply;
reply = getLineFromUser(); //assume this function works correctly
if(reply == "JAVA"){
System.out.println("OK to continue");
}
else {
System.out.println("Error - try again!");
}

i cant seem to see where i'm going wrong, thus cant get a correct version to work. I need it to keep repeating asking for a passwrod until its correct. Password equals JAVA.
Hope some1 can help, cheers.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2004
Location: Pakistan
Posts: 1,673
Reputation: nanosani is an unknown quantity at this point 
Rep Power: 8
Solved Threads: 50
Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

Re: code repeatedly 2 ask user 4 a password until correct (=Java) but cant c wots wrong.

  #2  
Aug 10th, 2004
if(reply == "JAVA"){
make this code as :

if(reply.equals("JAVA");

now it'll work properly. Strings are not compared by ==.
Reply With Quote  
Join Date: Aug 2004
Posts: 11
Reputation: srthomso is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
srthomso srthomso is offline Offline
Newbie Poster

Re: code repeatedly 2 ask user 4 a password until correct (=Java) but cant c wots wrong.

  #3  
Aug 10th, 2004
Thank you very much for your help - much appreciated!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 4:37 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC