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 is difference between final and finally in java?
What is unicode used for?
In which language JVM (Java Virtual Machine) is implemented
What is the final variable?
What are the differences between string, stringbuffer and stringbuilder?
Explain creating threads by implementing runnable class?
explain how many oops concepts available in java with realtime scenarios?
Explain notify() method of object class ?
What is map java?
Which api is provided by java for operations on set of objects?
What are three types of loops in java?
Can you call a method on a null object?