I am newbie in Java. Was looking at the below condition. The Type always return String but the condition always returns false. If I do direct "Test" == "Test" then it matches. And output for both the words are Test.
Can some one please let me know why it is false?
Thanks.
public static void main(String []args){
String word = "Test";
System.out.println((word.substring(0,1).toUpperCase() + word.substring(1)).getClass().getName());
System.out.println(word.substring(0,1).toUpperCase() + word.substring(1));
System.out.println(word.getClass().getName());
System.out.println(word);
if(word.substring(0,1).toUpperCase() + word.substring(1) == word)
{
System.out.println("t");
}
else
{
System.out.println("f");
}
}