Ultra fast mathematician wrong code

my code was working fine when i was taking all the inputs on different lines but to take input on same lime i modified my code
but now again its not working fine please tell me the error
the code is

   Scanner scn=new Scanner(System.in);
  String n1= scn.nextLine();
  int n=Integer.parseInt(n1);
   for(int j=0;j<n;j++) {
  String str=scn.nextLine();
  String[] string = str.split("");
  String str1=string[0];
  String str2=string[1];
  String str3="";
  for(int i=0;i<str1.length();i++) {
	  if(str1.charAt(i)==str2.charAt(i))  {
		  
		  str3+='0';
		  
	  }
	  else {
		  str3+='1';
	  }
  }
  System.out.println(str3);
}

Hi @vaibhavgupta.1919,you can also take the input on the same line simply.Either we can take the input on the same line with spaces in between or on the next lines.Both work in the same manner.

Please tell how to take two inputs on same line with space

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.