Answer:
Your program would run without error if you declared the first and second string variables before using them:
Modify the following:
first=input.nextLine();
second=input.nextLine();
to:
String first=input.nextLine();
String second=input.nextLine();
Explanation:
Required
Program to print two strings in forward and reversed order
<em>The program you added is correct. The only thing that needs to be done is variable declarations (because variables that are not declared cannot be used).</em>
<em></em>
So, you need to declared first and second as strings. This can be done as follows:
<u>(1) Only declaration</u>
String first, second;
<u>(2) Declaration and inputs</u>
String first=input.nextLine();
String second=input.nextLine();