-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFun31.java
More file actions
32 lines (22 loc) · 675 Bytes
/
Fun31.java
File metadata and controls
32 lines (22 loc) · 675 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package fun;
public class Fun31 {
public static void main(String[] args) {
System.out.println(isPalindrome(101));
System.out.println(isPalindrome(2112));
System.out.println(isPalindrome(99));
System.out.println(isPalindrome(21));
System.out.println(isPalindrome(2121));
}
public static boolean isPalindrome(int n) {//101
int num = n; //
int temp;
int reverseNum = 0;
for (; num != 0; ) {
temp = num % 10;
reverseNum = reverseNum * 10 + temp;
num = num / 10;
}
if (n == reverseNum) return true;
else return false;
}
}