Edit:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Question {
public static void main(String[] args) {
try {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String input = in.readLine();
if ("you're my daddy.".equals(input)) {
System.out.println("correct");
} else {
System.out.println("try again");
}
} catch (IOException ex) {
System.out.println("Error reading from System.in");
}
}
}
Another hint for String comparisons:
It is better to put the String constant in the first place of the comparison to avoid NullPointerExceptions.
if ("you're my daddy.".equals(input)) {
// ...
}
And a brief explanation of why == is not correct here:
This checks if two objects are the same (identity). Every time you write “you’re my daddy.” a new String is created. Therefore the comparison with == would never be true although the content of the String is identical.