Testcase failing though output is same

Scanner scn = new Scanner(System.in);

    int testCases = scn.nextInt();

    StringBuilder sb = new StringBuilder();

    while(testCases-- > 0){
        String str1 = scn.next();
        String str2 = scn.next();
        for(int i = 0; i < str1.length(); i++){
            if(str1.charAt(i) == str2.charAt(i)){
                sb.append('0');
            }
            else{
                sb.append('1');
            }
        }
    }
    System.out.println(sb);
    return;

this is my previous sol, why this was failing for the the 0th test case? i tried writting different code and submitted it and then downloaded the test case and it worled fine vscode. what’s wrong??

Hey @shruti_codess28,
Your logic for comparing the 2 strings is correct.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.