String Palindrome Number

Although the point is not fully justified as the string number is itself a string so It can be said to check is a string is palindrome or not ,and the method to check so is mentioned below.

We can convert a number into String, and after conversion, we can use the functions available with Strings for conversions.

Program to Check for Palindrome Numbers in Java is mentioned below:

Java




// Java Program to Check if a Number
// is Palindrome using String Class
import java.io.*;
import java.util.*;
 
// Driver Class
class GFG {
    // main function
    public static void main(String[] args)
    {
        String s;
 
        // Taking input using Scanner Class
        Scanner in = new Scanner(System.in);
 
        System.out.print("Enter Number = ");
        // Storing the the input value in s
        s = in.nextLine();
 
        // Length of the String
        int n = s.length();
        String rev = "";
 
        for (int i = n - 1; i >= 0; i--) {
            rev = rev + s.charAt(i);
        }
 
        // Printing the reversed Number
        System.out.println("Reverse Number = " + rev);
 
        // Checking Palindrome
        if (s.equals(rev))
            System.out.println("Palindrome = Yes");
        else
            System.out.println("Palindrome = No");
    }
}


Input:

Enter Number = 12345654321

Output:

Reverse Number = 12345654321
Palindrome = Yes

For more information, please refer to the complete article for Palindrome Number Program.



Palindrome Number Program in Java

A given number can be said palindromic in nature if the reverse of the given number is the same as that of a given number. In this article, we will write a Program to check if a number is a Palindrome Number in Java.

Example of Palindrome Number

Input : n = 46355364
Output: Reverse of n = 46355364
Palindrome : Yes

Input : n = 1234561111111111654321
Output: Reverse of n = 1234561111111111654321
Palindrome : Yes

Similar Reads

Methods to Check If a Number is a Palindrome Number in Java

There are certain methods to check if a Number is a Palindrome Number in Java as mentioned below:...

Palindrome BigInteger Number

...

String Palindrome Number

...