JavaAlgorithms/Misc/Palindrome.java
2017-07-16 22:14:29 +07:00

17 lines
374 B
Java

class Palindrome {
public String reverseString(String x){ //*helper method
String output = "";
for(int i=x.length()-1; i>=0; i--){
output += x.charAt(i); //addition of chars create String
}
return output;
}
public Boolean isPalindrome(String x){ //*palindrome method, returns true if palindrome
return (x.equalsIgnoreCase(reverseString(x)));
}
}