Skip to content

Commit 86ac332

Browse files
authored
Merge pull request #1 from earngpi/earngpi-version
create Palindrome.java
2 parents 0d10529 + 6d3c846 commit 86ac332

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Misc/Palindrome.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Palindrome {
2+
3+
public 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
7+
}
8+
return output;
9+
}
10+
11+
12+
public Boolean isPalindrome(String x){ //*palindrome method, returns true if palindrome
13+
return (x.equalsIgnoreCase(reverseString(x)));
14+
}
15+
16+
}

0 commit comments

Comments
 (0)