Here is my code and I am now quite confuse about String pool and Heap storage by this output.
public class String1 {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        String str = "abcd";
        String str1 = "" ;
        str1=str1+"abcd";
        if(str.equals(str1))
            System.out.println("True");
        else
            System.out.println("False");
        if(str == str1)
            System.out.println("True");
        else
            System.out.println("False");
    }
}
Now, I am creating String str and will be stored in string pool (Correct me if I am getting wrong!).
Now after concat str1 with string "abcd" they both have same value.
So, I think str and str1 should have same reference in String pool and So, 2nd if statement should print true but it prints false.
So, my question why str and str1 not getting same reference ?
 
     
     
     
    