Is palindrome or not

import java.util.*;
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
String str=sc.nextLine();
StringBuilder sb=new StringBuilder(str);
StringBuilder revstr=sb.reverse();
boolean bool=true;
if(sb.toString().equals(revstr.toString()))
{
System.out.print(bool);

	}
	else
	{
		bool=false;
		System.out.print(bool);
		}		
}

}
again i tried using arr concept but 2 test cases went wrong out of 4

@karthik1989photos,
Take as input N, a number. Take N more inputs and store that in an array. Write a recursive function which tests if the array is a palindrome and returns a Boolean value.

Now you are taking input as strings which stores only the first number. Hence you will always get answer as true.

Take input of N integers and then check for palindrome. Your input format is wrong. Also, don’t use inbuilt methods, try implementing a recursive solution.

i m not getting yet,plz provide the solution

@karthik1989photos,
It won’t help if we just give you the solution. Frame a solution and then if you face any issues we’ll help you with the code. You can do it. Just focus a little harder. Best of luck !!

For input use an integer array. And imagine that integer array as a string, where every index represents a character in the string.

import java.util.;
import java.util.
;
public class Main {
public static void main(String args[]) {
String rev="";
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++)
{
a[i]=sc.nextInt();
}
String str=sc.next();
char ch[]=str.toCharArray();
int length=str.length();

	for(int i=length-1;i>=0;i--)
	rev=rev+str.charAt(a[i]);
	if(str.equals(rev))
	System.out.println(true);
	else
	System.out.println(false);
}

}
where i went wrong testcases arepartially exceuting

@karthik1989photos,
https://ide.codingblocks.com/s/271211 please refer to this.

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.