Palindrome Number
This program was created to check if a number is a palindrome.
A palindrome is a number where if you take the middle number, the left and right side mirror the same numbers (i.e: 12321, 51415, 121).
The code has been modified slightly and now uploaded to the site.
Solution.java
import java.util.Arrays;
public class Solution {
public static void main(String[] args) {
System.out.println(isPalindrome(121));
System.out.println(isPalindrome(-121));
System.out.println(isPalindrome(10));
System.out.println(isPalindrome(-101));
}
public static boolean isPalindrome(int x) {
String concat = "";
// int value = -1;
String convertToString = x + "";
char[] differentiate = convertToString.toCharArray();
System.out.println(Arrays.toString(differentiate));
for (int i = 0; i < differentiate.length; i++){
concat += differentiate[differentiate.length - i - 1] + "";
}
if (concat.equals(x + "")){
return true;
}
else {
return false;
}
}
}