Results 1 to 3 of 3
  1. #1
    OfficerFarva is offline Member
    Join Date
    Aug 2014
    Posts
    1
    Rep Power
    0

    Default I'm just starting to learn java and have a question.

    So I've been making really small projects and deleting them after I'm done. I just got done coding this and expected it to work, but it doesn't, and I'm sure I've completely violated an obvious rule. Can anyone help? All I'm trying to do is make a login system.

    code - Pastebin.com

  2. #2
    FlipPoker@gmail.com is offline Senior Member
    Join Date
    Mar 2011
    Posts
    103
    Rep Power
    0

    Default Re: I'm just starting to learn java and have a question.

    For starters, when comparing String objects for equality, use equals():

    //if(userPwIn == pw) //WRONG
    if(userPwIn.equals(pw)) //RIGHT
    {
    pwTrue = true;
    }

    The equals() method checks to see if two String objects have character sequences that are identical (which is what you want). The == operator in this case checks to see if the two String references, userPwIn and pw point to the same String object. In this case, they do not.

  3. #3
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,087
    Rep Power
    4

    Default Re: I'm just starting to learn java and have a question.

    Two things:
    1) Put code on this site, not on an external site. I don't like being taken to random sites. The [code][/code] tags will help enormously.
    2) Don't compare Strings using ==, instead use equals().
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

Similar Threads

  1. Starting Java GUI
    By nhrnjic in forum New To Java
    Replies: 3
    Last Post: 04-27-2012, 04:40 PM
  2. For anyone starting out in Java
    By ManInTheMiddle in forum Reviews / Advertising
    Replies: 3
    Last Post: 03-30-2012, 04:12 PM
  3. starting java
    By ashwin kumar in forum New To Java
    Replies: 11
    Last Post: 06-08-2011, 10:47 AM
  4. Just starting to learn java~
    By bakalove in forum New To Java
    Replies: 3
    Last Post: 05-26-2011, 03:10 AM
  5. Help, starting with java
    By mathias in forum New To Java
    Replies: 2
    Last Post: 08-15-2007, 08:15 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •