Results 1 to 3 of 3
  1. #1
    MutatedGamers is offline Member
    Join Date
    Nov 2012
    Posts
    2
    Rep Power
    0

    Default Not sure why my code isnt working

    import java.util.Scanner;

    public class MainText
    {
    Scanner UserInput = new Scanner(System.in);


    public static void main(String args[])
    {


    System.out.println("Hello... welcome to hell.");
    try {
    Thread.sleep(2000);
    }
    catch (InterruptedException e) {

    }
    System.out.println("There are many demons here in hell, Do you want to meet them?");


    String demons = UserInput.nextLine();
    if (demons == ("yes"))
    {
    System.out.println("You died");

    }
    else if (demons == ("no"))
    {
    System.out.println("You ran away.");
    }

    else
    {
    System.out.println("Try again! yes or no");
    }





    }
    }

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    786
    Rep Power
    5

    Default Re: Not sure why my code isnt working

    Do you have a question?
    Maybe this helps: Java: String Comparison

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Not sure why my code isnt working

    Please go through the Forum Rules -- particularly the third paragraph.

    Also Guide For New Members and BB Code List - Java Programming Forum


    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 1
    Last Post: 03-25-2012, 02:40 AM
  2. Replies: 59
    Last Post: 05-22-2011, 08:37 AM
  3. Why isnt this working?
    By GoingThroAPhase in forum New To Java
    Replies: 4
    Last Post: 04-03-2010, 02:36 AM
  4. My rotate 2d pos method isnt working correctly..
    By Addez in forum New To Java
    Replies: 5
    Last Post: 12-01-2009, 09:04 AM
  5. Replies: 6
    Last Post: 11-12-2009, 10:50 AM

Posting Permissions

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