forked from ronijpandey/Java-Codes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPalindrome_or_not.java
More file actions
25 lines (21 loc) · 804 Bytes
/
Palindrome_or_not.java
File metadata and controls
25 lines (21 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package javacodes;
/*
Write a program to check the given number is palindrome or not?
Descritpion : A Palindrome number is a number that remains the same when its digits are reversed. Like 16461, for example: we take 121 and reverse it, after revers it is same as original number
*/
import java.util.Scanner;
class Palindrome_or_not {
public static void main(Sting args[])
{
Scanner x = new Scanner(System.in);
String st=x.next();
String w=""; // Creating new string to apply algo on!
int i;
for(i=0;i<st.length();i++)
w=st.charAt(i)+w; //Reversing the String and Storing it.
if(st.compareTo(w)==0) //Comparing the string to original string
System.out.prinltn("Number is Pallindrome");
else
System.out.println("Number is Not Pallindrome");
}
}