PLEASE TELL ME THE ERROR IN THE CODE AS THE COMPILER IS NOT GIVING ANY ERROR BUT I AM NOT GETTING ANY OUTPUT.
No output : ultra fast mathematicians
HI @mananaroramail,
can you please save the code in a online coding blocks ide and send the url … I cannot access your code .
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String [][] arr = new String [n][3];
for(int i = 0 ; i<n ; i++)
{
arr[i][0] = sc.nextLine();
sc.nextLine();
arr[i][1] = sc.nextLine();
}
for(int i = 0 ;i < n ; i++ )
{
StringBuilder str = new StringBuilder("");
for(int j = 0 ; j<arr[i][0].length() ; j++)
{
if(arr[i][0].charAt(j) != arr[i][1].charAt(j))
{
str.append(“1”);
}
else
{
str.append(“0”);
}
}
String st = str.toString();
arr[i][2] = st;
}
for(int i = 0 ; i < n ; i++)
{
System.out.println(arr[i][2]);
}
}
}
I cannot review this code … Save it on online ide please . Directly sending code changes the code …
You are taking input wrong . I’ve made the correction in the following code ,.
What’s the difference between sc.nextLine() and sc.next()
next() can read the input only till the space. It can’t read two words separated by space. Also, next() places the cursor in the same line after reading the input. nextLine() reads input including space between the words