Palindromic Number in Java

Published on 11 October 2020 (Updated: 11 October 2020)

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 < 0) {
            System.out.println("Usage: please input a non-negative integer");
        } else {

    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.

Note: The solution shown above is the current solution in the Sample Programs repository as of Oct 11 2022 01:31:51. The solution was first committed on Oct 11 2020 18:07:28. As a result, documentation below may be outdated.

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.