Skip to content

Commit ea2c7de

Browse files
committed
create palindrome-number.java
1 parent 9b87d72 commit ea2c7de

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Java/palindrome-number.java

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution {
2+
public boolean isPalindrome(int x) {
3+
String _x = x+""; // integer convert string
4+
String rev = ""; // store reverse
5+
int i = 0;
6+
for(i = _x.length()-1; i>=0; i--){
7+
rev += _x.charAt(i);
8+
}
9+
10+
if(_x.compareTo(rev) == 0){
11+
// correct
12+
return true;
13+
}
14+
else{
15+
return false;
16+
}
17+
18+
}
19+
}

0 commit comments

Comments
 (0)