I have to compare Boolean values in a array by using the isPalindrom() method. I cant not get my program to accurately return the answer if an array is or is not a palindrome. It just always returns true instead of false when I purpose use a non palindrome answer. Code:
public Boolean isPalindrome()
{
Boolean result = true;
for(int i=0;i<bits.length;i++)
{
Boolean a = bits[i];
Boolean b = bits[bits.length - i - 1];
if(a!=b)
result = false;
}
return result;
}
Boolean
? – chrylis -cautiouslyoptimistic-Boolean
) and the primitives (boolean
). Unless you're putting it into a collection, there's almost never a reason to use the wrapper forboolean
. – chrylis -cautiouslyoptimistic-