First, missing a few semi-colons so as is this won't compile. Second,


if(str1.charAt(i-1) == str1.charAt(j-1))

I believe you want to compare str1 to str2, not str1 to itself. Next, you...