If you do
str1 = str2;
System.out.println( str1.equals(str1) );
or
System.out.println( str1.equals(str2) );
or
System.out.println( str1.equals( (str1=str2) ) );
rather than:
System.out.println( str1.equals(str1=str2) );
it will work.
The third alternative indicates that this may be a problem related to the order of evaluation of an expression. Looks like in your original code
Java took str2 before it assigned it to str1, and compared its string with str1 before the assignment!