All pastes #356747 Raw Edit

Unnamed

public java v1 · immutable
·published 2007-02-15 07:15 UTC
rendered paste body
public class recursiveUtilities {	public static void main(String[] args) {		int[] TestArray = {30, 8, 31, 400, 3, 630, 70, 4, 7, 20};		recursiveUtilities h = new recursiveUtilities();		char[] palindromeCheck = {'m', 'o', 'a', 'l', 'l', 'a', 'o', 'm'};		boolean check = h.isPalindrome(palindromeCheck, 0, palindromeCheck.length-1);		System.out.println("isPalindrome? . . . " + check);	}		public boolean isPalindrome(char[] array, int startIndex, int endIndex){				if (startIndex == endIndex)                {                      return true; //im assuming a single character is a palindrome(?)                 }                if (array[startIndex]!=array[endIndex]){  //the endIndex check was not really needed i dont think			return false; //correct		}		else{						return isPalindrome(array, startIndex+1, endIndex-1);			//return true;     /*IMPORTANT: YOU CANNOT JUST RETURN TRUE HERE. YOU ARE ASSUMING ALL OF THE RECURSIVE CALLS WILL RETURN TRUE BY DOING  THIS. WRONG WRONG WRONG. YOU NEED TO USE THE RESULTS THAT THE RECURSIVE CALLS PASS BACK, NOT JUST TOSS THEM AWAY AFTER FINDING THEM. */			}			} }