Help me in solving GSJ214 problem

My issue

I have solved the problem, but its showing a runtime error which i dont know how to solve

My code

// Update the '_' in the code below
import java.util.Scanner;

class Codechef
{
	public static void main (String[] args)
	{
        Scanner read = new Scanner(System.in);
        
        // accept the count of test cases given in the 1st line
        int t = read.nextInt();
        for(int i=0; i<=t; i++)
        {
            String s = read.next();
            // create a variable X which stores the value of string S concatenated with itself
            String x = s + s;
            // output the variable X
            System.out.println(x);
        }
	}
}

Learning course: Logic Building in Java
Problem Link: CodeChef: Practical coding for everyone

Here is the updated code
// Update the ‘’ in the code below
// Update the '
’ in the code below
import java.util.Scanner;

class Codechef
{
public static void main (String args)
{
Scanner read = new Scanner(System.in);

    // accept the count of test cases given in the 1st line
    int t = read.nextInt();
    for(int i=0; i<t; i++)
    {
        String s = read.next();
        // create a variable X which stores the value of string S concatenated with itself
        String x = s + s;
        // output the variable X
        System.out.println(x);
    }
}

}

1 Like