Update Palindrome.java

Test cases where String x is null or has a length of 0 or 1 for FirstWay method.
This commit is contained in:
jasonptong
2018-12-22 17:27:31 -08:00
committed by GitHub
parent 084548d96e
commit a5bf69fcbd

View File

@ -10,7 +10,9 @@ class Palindrome {
public Boolean FirstWay(String x){ //*palindrome method, returns true if palindrome public Boolean FirstWay(String x){ //*palindrome method, returns true if palindrome
return (x.equalsIgnoreCase(reverseString(x))); if(x == null || x.length() <= 1)
return true;
return (x.equalsIgnoreCase(reverseString(x)));
} }
public boolean SecondWay(String x) public boolean SecondWay(String x)