I've searched everywhere and have found lots of examples on how to tell if it is a palindrome but none showing how to do it with an array. So far I have,
I'm not sure how to include an array in this. Any help is greatly appreciated
public static void main(String[] args) {
while (true) {
display(check(retrieveInput()));
}
}
public static String retrieveInput() {
Scanner scan = new Scanner(System.in);
return scan.next();
}
public static boolean check(String input) {
boolean check = false;
try {
Integer.parseInt(input);
if (input.charAt(0)==input.charAt(4) && input.charAt(1)==input.charAt(3))
check = true;
} catch(Exception e) {
check = false;
}
return check;
}
public static void display(boolean check) {
if(check) System.out.println("Is a five-digit palindrome.");
else System.out.println("Is not a five-digit palindrome.");
I'm not sure how to include an array in this. Any help is greatly appreciated