Possible Duplicate:
How do I compare strings in Java?
yes the title sounds funny, I am working on this project for a special someone, and I want to ask her out by writing her a simple program. I am having some trouble though with the execution of this idea. I have a pseudo code ish plan in my mind but need help executing it. I was planning on having her input yes or no answers to questions in the console and have the program respond with answers based on her inputs. my Idea was her input yes or no answers to questions, and then say something like If input is "yes" then print this statement, else if "no" print this statement. I am currently having problems getting the if else part to work. I cant have strings act like booleans in an if statment, so I need some help with that. code I started with:
import java.io.*;
public class ask {
public static void main(String [] args) throws IOException {
BufferedReader in = new BufferedReader
(new InputStreamReader(System.in));
String answer;
System.out.print("Would you like to go out with me? ");
System.out.flush();
answer = in.readLine();
Boolean hope = Boolean.valueOf("yes");
if (answer == hope) {
System.out.print("Awesome!");
}
else
System.out.print("Not awesome!");
}
}
obviously Im not actually using that question those responses, im just putting it as in example just to get the program itself to work. I cannot compare answer to hope because one is boolean and the other is a string, I also cannot do string with string, so how do I get this to work. Any ideas? Edit: Guys just to say, I know she will say yes, this is just a funny silly way to ask her out. I will be there IN PERSON with her while doing this, and I will tell her only to use yes or no so that way this works, its just a small simple project. Don't need any advice or opinion on anything other than how to get this to work please! Thanks!