Possible Duplicate:
Java String.equals versus ==
I am using an if statement in java to determine weather the person is a male or female by asking weather he is a boy or a girl. This is quite a stupid statement but my query is no matter what i input i always get "you are a female!" which is quite annoying. Could you please help? This is the code
import java.util.Scanner;
class ifstatement {
public static void main( String args[] ) {
System.out.print( "please enter boy or girl as an input:" );
Scanner x = new Scanner( System.in );
String a = x.nextLine();
if ( a == "boy" ) {
System.out.print( "You are a male" );
}
else {
System.out.print( "You are a female!" );
}
}
}