mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-08 10:15:51 +08:00
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:
@ -10,6 +10,8 @@ class Palindrome {
|
|||||||
|
|
||||||
|
|
||||||
public Boolean FirstWay(String x){ //*palindrome method, returns true if palindrome
|
public Boolean FirstWay(String x){ //*palindrome method, returns true if palindrome
|
||||||
|
if(x == null || x.length() <= 1)
|
||||||
|
return true;
|
||||||
return (x.equalsIgnoreCase(reverseString(x)));
|
return (x.equalsIgnoreCase(reverseString(x)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user