Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: A little question

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default A little question

    How would i store data which is provided in letters, lets say i can do, as you can see the data is stored in numbers.
    int boys, girls;
    boys = 8;
    girls = 8;
    I would like to make a password checking program. And i would like to store a password, how would i do this since this is not working:
    int password;
    password = test123;


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: A little question

    Have you heard of Strings?
    Improving the world one idiot at a time!

  3. #3
    Junior Member
    Join Date
    Jul 2013
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: A little question

    Quote Originally Posted by Junky View Post
    Have you heard of Strings?
    Yes, i've heard of them although i'm not 100% familiar with them...

  4. #4
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: A little question

    Then I suggest you become 100% familiar with them. Read a textbook, Google for a tutorial, search for code examples. Put all the information together and try writing some test code. Then tackle your password problem.
    Improving the world one idiot at a time!

  5. #5
    Junior Member
    Join Date
    Jul 2013
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: A little question

    Quote Originally Posted by Junky View Post
    Then I suggest you become 100% familiar with them. Read a textbook, Google for a tutorial, search for code examples. Put all the information together and try writing some test code. Then tackle your password problem.
    So i've read something about strings, but my script isn't working, it always goes the 'else' route.

    import java.util.Scanner;
    public class passwordCheck {
    public static void main(String args[]){
    String password = "test123";
    String username = "variumzky";
    Scanner check = new Scanner(System.in);
    System.out.println("Enter your username here: ");
    if (check.nextLine() == username){
    System.out.println("Enter your password");
    }else{
    System.out.println("No username like that was recognized in our database");
    check.close();
    }

    }
    }

  6. #6
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: A little question

    Use the equals method when comparing objects (Strings are objects).
    Improving the world one idiot at a time!