Solution Review: Is ArrayList a Palindrome?
Have a look at the solution to the 'Is ArrayList a Palindrome?' challenge.
We'll cover the following...
Rubric criteria
Solution
Press + to interact
import java.util.ArrayList;class Palindrome{public static void main(String args[]){ArrayList<String> str = new ArrayList<String>();// Adding elementsstr.add("m");str.add("a");str.add("d");str.add("a");str.add("m");System.out.println(checkPalindrome(str));}public static boolean checkPalindrome(ArrayList<String> str){if (str.size() == 0){return true;}else{boolean cont = true; // Keep track whether it's plaindrome or notfor(int i = 0; i < str.size()/2 && cont; i++){if (str.get(i) != str.get(str.size()-1-i)) // Comparing values{cont = false; // Match not found}}if (cont)return true;elsereturn false;}}}
Rubric-wise explanation
Point 1: ...