We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 084548d commit a5bf69fCopy full SHA for a5bf69f
Others/Palindrome.java
@@ -1,6 +1,6 @@
1
class Palindrome {
2
3
- private String reverseString(String x){ //*helper method
+ private String reverseString(String x){ //*helper method
4
String output = "";
5
for(int i=x.length()-1; i>=0; i--){
6
output += x.charAt(i); //addition of chars create String
@@ -10,7 +10,9 @@ private String reverseString(String x){ //*helper method
10
11
12
public Boolean FirstWay(String x){ //*palindrome method, returns true if palindrome
13
- return (x.equalsIgnoreCase(reverseString(x)));
+ if(x == null || x.length() <= 1)
14
+ return true;
15
+ return (x.equalsIgnoreCase(reverseString(x)));
16
}
17
18
public boolean SecondWay(String x)
0 commit comments