Results 1 to 3 of 3
- 11-20-2012, 09:19 PM #1
Member
- Join Date
- Nov 2012
- Posts
- 2
- Rep Power
- 0
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");
}
}
}
- 11-20-2012, 09:24 PM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
Re: Not sure why my code isnt working
Do you have a question?
Maybe this helps: Java: String Comparison
- 11-20-2012, 09:27 PM #3
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
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
this code is not working I Dont know why ? Public void close the last code!!
By lukote04 in forum New To JavaReplies: 1Last Post: 03-25-2012, 02:40 AM -
Why isnt my JAR file not working outside of the main folder with bluej classes?
By rajkobie in forum New To JavaReplies: 59Last Post: 05-22-2011, 08:37 AM -
Why isnt this working?
By GoingThroAPhase in forum New To JavaReplies: 4Last Post: 04-03-2010, 02:36 AM -
My rotate 2d pos method isnt working correctly..
By Addez in forum New To JavaReplies: 5Last Post: 12-01-2009, 09:04 AM -
The code isnt working unless I add print statements at diffrent points!:confused:
By Addez in forum New To JavaReplies: 6Last Post: 11-12-2009, 10:50 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks