Palindromic Number in Java

Published on 28 April 2022 (Updated: 25 September 2022)

Palindromic Number in Java

Welcome to the Palindromic Number in Java page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

public class PalindromicNumber {

    public static void main(String[] args) {
        Long num;
        try {
            num = Long.parseLong(args[0]);
        } catch (Exception ignored) {
            num = null;

        if (num == null || num.toString().length() < 2) {
            System.out.println("Usage: please input a number with at least two digits");
        } else {

     * Checks if the number is palindromic or not
    public static boolean isPalindromic(Long num) {
        char[] numChars = String.valueOf(num).toCharArray();
        for (int i = 0; i < numChars.length / 2; i++) {
            if (numChars[i] != numChars[numChars.length - 1 - i])
                return false;
        return true;

Palindromic Number in Java was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.