Write the code for Palindrome ?
Answers were Sorted based on User's Feedback
Answer / aslam
public boolean isPaliandrome(String txtToCheck){
StringBuffer strb1 = new StringBuffer(txtToCheck).reverse();
if(txtToCheck.equals(strb1.toString()))
return true;
return false;
}
| Is This Answer Correct ? | 5 Yes | 4 No |
Answer / suresh royal
mport java.io.*;
public class Palindrome {
public static void main(String [] args){
try{
BufferedReader object = new BufferedReader(
new InputStreamReader(System.in));
System.out.println("Enter number");
int num= Integer.parseInt(object.readLine());
int n = num;
int rev=0;
System.out.println("Number: ");
System.out.println(" "+ num);
for (int i=0; i<=num; i++){
int r=num%10;
num=num/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!");
}
}
}
| Is This Answer Correct ? | 1 Yes | 0 No |
What's a method in programming?
What are the advantages of java?
Explain the difference between private, public, package and protected in java?
What is parsing a sentence?
What is a default constructor and also define copy contrucyor?
In a class implementing an interface, can we change the value of any variable defined in the interface?
String is a immutable objects . it means that string does not change........... But it will be chang......... { String s="kapil"; String s1="raj"; String s=s1; then print(.......) The String has been changed .. how it is possible and why its called immutable objects
What is static synchronization?
Why stringbuffer is faster than string?
What is a programming object?
Write a program for recursive Traverse?
Can we define static methods inside interface?