Palindrome (Numbers) Program Using Java With I/O Stream

Introduction

 
In this blog, I will explain about Palindrome (Numbers) program, using Java. It is very simple in Java Programming. The output will be displayed in the Run module.
 
Software Requirement
 
JDK1.3.
 
Simple Program
  1. import java.io.*;  
  2. class palind {  
  3.  public static void main(String arg[]) throws IOException {  
  4.   DataInputStream dr = new DataInputStream(System.in);  
  5.   System.out.println("Enter the Number : ");  
  6.   int no = Integer.parseInt(dr.readLine());  
  7.   int d, r, a;  
  8.   r = 0;  
  9.   a = no;  
  10.   while (no != 0) {  
  11.    d = no % 10;  
  12.    r = r * 10 + d;  
  13.    no = no / 10;  
  14.   }  
  15.   if (a == r)  
  16.    System.out.println("The given Number is Palindrome");  
  17.   else  
  18.    System.out.println("The given Number is Not Palindrome");  
  19.  }  
  20. }   
Explanation
 
In this blog, I explained about Palindrome (Numbers) program, using Java. The output will be displayed in the Run module.
 
Output
 
s