When I put "I " into str
, "It is I" is not printed,
But I put "I" into str
, "It is I" is printed.
Can anyone explain about this behaviour. Below is my code.
Code:
String str = "I "; // in = "I"
StringTokenizer st = new StringTokenizer(str, " ", false);
String typeCharater="";
if( st.hasMoreTokens() ) {
typeCharater = st.nextToken();
}
} else if( typeCharater == "I" ) {
System.out.println("It is I");
}