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 2 of 2

Thread: What is wrong with my code? Need Help! ASAP Thank you

  1. #1
    Junior Member
    Join Date
    Oct 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default What is wrong with my code? Need Help! ASAP Thank you

    Scanner console = new Scanner(System.in);
    System.out.print("What is your favorite color? ");
    String name = console.next();
    if (name == "blue") {
    if (name.equals("blue")) {
    System.out.println("Mine, too!");
    }
    }


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: What is wrong with my code? Need Help! ASAP Thank you

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Please post your code correctly using code or highlight tags per the above link.

    Do not use '==' to compare String objects. Use the equals() method instead.

Similar Threads

  1. [SOLVED] Need Help ASAP with my code. should be an easy one for you guys!
    By GalBenH in forum What's Wrong With My Code?
    Replies: 13
    Last Post: December 5th, 2011, 08:27 PM
  2. Help ! merge this code into 1 main method . ASAP :( tnx
    By anitsirc in forum Object Oriented Programming
    Replies: 2
    Last Post: November 23rd, 2011, 11:53 AM
  3. [SOLVED] Can someone help me with this code asap
    By Darkcore123 in forum What's Wrong With My Code?
    Replies: 12
    Last Post: November 14th, 2011, 11:55 AM
  4. new to java need help with code asap
    By stark007 in forum Object Oriented Programming
    Replies: 1
    Last Post: November 13th, 2011, 01:25 PM
  5. Need some help with this code - Asap
    By Th3T3chGuy in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 10th, 2011, 07:17 AM