palindrome

palindrome

View Answers

August 26, 2008 at 9:55 AM

Hi friend,


Example to check the number is a palindrome

import java.io.*;

public class PalindromeExample {
public static void main(String [] args){
try{
BufferedReader br = new BufferedReader(
new InputStreamReader(System.in));
System.out.println("Enter nober");
int no= Integer.parseInt(br.readLine());
int n = no;
int rev=0;
System.out.println("Number: ");
System.out.println(" "+ no);
for (int i=0; i<=no; i++){
int r=no%10;
no=no/10;
rev=rev*10+r;
i=0;
}
System.out.println("After reversing the number: "+ " ");
System.out.println(" "+ rev);
if(n == rev){
System.out.print("Number is palindrome!");
}
else{
System.out.println("Number is not palindrome!");
}
}
catch(Exception e){
System.out.println("Out of range!");
}
}
}


Thanks

August 26, 2008 at 7:46 PM

Read for more information about palindrome at:

http://www.roseindia.net/java/beginners/Palindrome.shtml


Thanks

Amardeep

August 26, 2008 at 10:31 PM

For String :

public class Palindrome {
public static void main(String[] args) {
String str1 = "eye", str2 = "bye";
System.out.println("Palindrome detection");
System.out.println(str1 + " "
+ isPalindrome(str1));
System.out.println(str2 + " "
+ isPalindrome(str2));
}
static boolean isPalindrome(String s) {
int left = 0;
int right = s.length() - 1;
while (left < right) {
if (s.charAt(left) != s.charAt(right))
return false;
left++;
right--;
}
return true;
}
}

thanks
tekchand









Related Tutorials/Questions & Answers:
Palindrome
Palindrome  program to verify palindrome
palindrome
palindrome  write a program to print palindrome numbers between 500 to 700
Advertisements
palindrome
palindrome  how to write in string of palindrome   import... is palindrome"); } else{ System.out.println("String is not palindrome
palindrome
palindrome  program to find the given string is palindrome or not   Hi Friend, Try the following code:ADS_TO_REPLACE_1 import java.util.... is palindrome"); } else{ System.out.println("String is not palindrome
palindrome
palindrome  how to write in string of palindrome?   import... is palindrome"); } else{ System.out.println("String is not palindrome
PALINDROME
PALINDROME  how to find palindrome of a number WITHOUT using a string... == reversedNumber){ System.out.print("Number is palindrome!"); } else{ System.out.println("Number is not palindrome!"); } } catch(Exception e){ System.out.println(e
java palindrome
java palindrome  sir i need java program to print 1)integer palindrome 2)string palindrome
prime palindrome
prime palindrome  Hi I want to write a program in pascal that ask a user to input a number, the program then list all the prime number that are palindrome below the number entered. thks
prime palindrome
prime palindrome  Hi I want to write a program that ask a user to input a number, the program then list all the prime numbers that are palindrome below the number entered. In pascal language Thanks
To check a palindrome number?
To check a palindrome number?  program to check a number is palindrome or not using recursion?(wihout converting to string
ModuleNotFoundError: No module named 'palindrome'
ModuleNotFoundError: No module named 'palindrome'  Hi, My Python... 'palindrome' How to remove the ModuleNotFoundError: No module named 'palindrome' error? Thanks   Hi, In your python environment you
palindrome - Java Beginners
palindrome  example of java program if it is a palindrome or not palindrome   Hi friend, Example to check the number is a palindrome...){ System.out.print("Number is palindrome!"); } else
palindrome - Java Beginners
is palindrome. A word is said to be palindrome if it reads the same forward... noon is a palindrome. Enter a word: moon moon is not a palindrome.  Hi...)) { System.out.println(str + " is a palindrome"); } else { System.out.println(str
palindrome - Java Beginners
palindrome  determines whether or not it is a palindrome. if the number is not five... == digit4)){ System.out.print("Number is palindrome!"); } else{ System.out.println("Number is not palindrome!"); } } catch(Exception e  
complete the code (palindrome) - Java Beginners
complete the code (palindrome)  Write a program that checks if a word is palindrome. A word is said to be palindrome if it reads the same forward...: noon noon is a palindrome. Enter a word: moon moon is not a palindrome
palindrome - Java Beginners
palindrome in java code  I need an example of palindrome in Java ...;& (digit2 == digit4)){ System.out.print("Number is palindrome!"); } else{ System.out.println("Number is not palindrome!"
ModuleNotFoundError: No module named 'Trial-Palindrome'
ModuleNotFoundError: No module named 'Trial-Palindrome'  Hi, My... named 'Trial-Palindrome' How to remove the ModuleNotFoundError: No module named 'Trial-Palindrome' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'pp-palindrome'
ModuleNotFoundError: No module named 'pp-palindrome'  Hi, My... 'pp-palindrome' How to remove the ModuleNotFoundError: No module named 'pp-palindrome' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'qq_palindrome'
ModuleNotFoundError: No module named 'qq_palindrome'  Hi, My... 'qq_palindrome' How to remove the ModuleNotFoundError: No module named 'qq_palindrome' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'xj_palindrome'
ModuleNotFoundError: No module named 'xj_palindrome'  Hi, My... 'xj_palindrome' How to remove the ModuleNotFoundError: No module named 'xj_palindrome' error? Thanks   Hi, In your python
palindrome - Java Beginners
palindrome  Write a program to find whether a given string is a palindrome or not  Hi Friend, Try the following code: import java.util.*; public class CheckPalindrome{ public static void main(String[] args
palindrome array problem
palindrome array problem  I'm having trouble figuring this assignment out. Can someone please help me? Generate (write the code) and save in an array Palidrome[250][5] all the 5 letter words using {a, b, c} Write the code
palindrome - Java Beginners
palindrome  import java.io.*; class Palindrome { System.out.println("Enter a word:"); BufferedReader br=new BufferedReader(new InputReaderStream(System.in)); String word; word=br.readLine(); public static void main
Java Program to check Palindrome
Java Program to check Palindrome In this section, you will learn about palindrome in java and how to check any number that is palindrome or not. First of all what is palindrome number?, this is the number that the original number
To find palindrome no in a file - Java Beginners
To find palindrome no in a file  hi all i am having a problem...I wanted to write one java program where i have to count the no of palindrome in a file. I tried it with my own but not able to get result.pls help me out  
Palindrome Number Example in Java
Palindrome Number Example in Java    ... the palindrome number and how to determine any number is palindrome or not. First of all we are going to read about the palindrome number.  This is the number
Finding all palindrome prime numbers - Java Beginners
Finding all palindrome prime numbers  How do i write a program to Find all palindrome prime numbers between two integers supplied as input (start and end points are excluded
Check whether the number is palindrome or not
Check whether the number is palindrome or not A palindrome is a word, phrase... is palindrome or not. You can check it in various ways but the simplest method...; } if (n == reversedNumber) { System.out.print("Number is palindrome
The Array Palindrome Number in Java
The Array Palindrome Number in Java       This is a Java simple palindrome number program. In this section you will read how to uses palindrome one dimensional array
Palindrome program in Java
Palindrome program in Java helps programmers to determine if a number or string is palindrome or not. palindrome number or string remains unchanged when.... The logic used in Java program behind finding a number or sting is palindrome
how to write a function to print for finding the longest palindrome in the given string
how to write a function to print for finding the longest palindrome in the given string  how to write a function to print for finding the longest palindrome in the given string
Program to display palindrome numbers between some range
Program to display palindrome numbers between some range  Hi!I want a java program to display palindrome numbers between 100 to 1000.can you please explain me the logic with an example   import java.util.*; public
Check whether the sum of alternate digit of a number is palindrome or not.
Check whether the sum of alternate digit of a number is palindrome... by the user is palindrome or not. So, firstly we have to find the sum... of this number be 2+4+6 i.e 12) and then check whether this sum is palindrome
Find Numbers which are palindrome and prime
Find Numbers which are palindrome and prime In this section, you will learn how to find the numbers from 1 to 500 which are palindrome and prime. To compute...() of boolean type. Now the list contains all the numbers which are palindrome
Panlindrome
Panlindrome  Write an program in java for palindrome sequences
Re: NEEDS CONSULTANCY - Java Interview Questions
Re: NEEDS CONSULTANCY  how to check a string is palindrome or not without using any inbuilt method
java question
java question  input any number and check if sum of alternate digit is palindrome
programes on strings
entered string is palindrome or not.   Have a look at the following link...)){ System.out.println("String is palindrome"); } else{ System.out.println("String is not palindrome
java
is palindrome or not...,can you please help me or give codes   import... is palindrome"); } else{ System.out.println("String is not palindrome
java program 12
number is palindrome or not by taking from input Buffer reader(console).  ...]; } if(st.equalsIgnoreCase(reversedSt)){ System.out.println("String is palindrome"); } else{ System.out.println("String is not palindrome
writig a program - Java Beginners
writig a program  Write an application that reads in a five digit integer and determines whether or not it is a palindrome. if the number is not five digits long, displays an error message indicating the problem to the user
prime palendrome
prime palendrome  Hi I want to write a program that ask a user to input a number, the program then list all the prime number that are palindrome below the number entered. Thks
Zoho interview Quest
Zoho interview Quest  Given a string , you have to predict whether it can be changed into a palindrome or not by changing the positions of the characters Eg. Tests Yes Explanation:tests can be changed to tsest or stets
Plz help with third Question - Java Beginners
that determines whether or not a string is a palindrome. (A palindrome reads...)){ System.out.println("String is Palindrome"); } else{ System.out.println("String is not a Palindrome"); } } } 2) import java.io.*; import java.util.regex.
java - Java Beginners
Java palindrome program code  Can anyone Explain me the Java palindrome with the help of an example or program code in Java.Thanks in advance!! ...; (digit2 == digit4)){ System.out.print("Number is palindrome!"
gui question
it is a palindrome or not. hint: abba is a palindrome   import java.awt.*; import... is palindrome"); } else{ JOptionPane.showMessageDialog(null,"String is not palindrome"); } } }); JPanel p=new JPanel
check where is error - JSP-Interview Questions
javscsript program function palindrome() { var string... == reverse(string)) { alert("this is djfksjfja palindrome"); } else { alert("this is not a palindrome
computers - Java Beginners
this stack to check whether a given string is a palindrome or not  Hi...); if(n == rev){ System.out.print("Number is palindrome!"); } else{ System.out.println("Number is not palindrome!"); } } catch
getChars method
getChars method  class VijayKrishna { public static void main(String args[]) { String palindrome = "Dot saw I was Tod"; int len = palindrome.length(); char tempCharArray[] = new char[len]; char charArray
about predefine classes.....
....pls help like below code is given in program of palindrome BufferedReader

Ads