Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

programme

Ads

 
 

Share on Google+Share on Google+

ashhu
programme
1 Answer(s)      8 years ago
Posted in : Java Beginners
Ads
View Answers

April 30, 2009 at 4:11 PM


Hi Friend,

Please visit the following link to get the stack implementation:

http://www.roseindia.net/java/example/java/util/StackImplement.shtml


Use following code to check whether the string is palindrome or not:

import java.util.*;

public class CheckPalindrome{
public static void main(String[] args) {
String str="madam";
Stack s= new Stack();
int i,count=0;
char array[]=str.toCharArray();

for(i=0;i<array.length;i++) {
char arr=array[i];
s.push(arr);
}
for(i=0;i<array.length/2;i++) {
char st=array[i];
Object ob=s.pop( );
if(st==ob) {
count++;
}
}
if(count==array.length/2) {
System.out.println("String is Palindrome");
}
else{
System.out.println("String is not a Palindrome");
}
}
}

Thanks

Ads









Related Tutorials/Questions & Answers:
programme
programme  Using an ATM, customer can access their bank accounts in order to credit/debit cash and check their account balances.You have to write c programme to implement a simple ATM for 15 customers. Initially you have to store
java programme
java programme   1.....programme for reading 10 values for 10 variables using scanner class 2....declares all types of primitive data inside main method
Advertisements
java programme
java programme   i have to write a java programe that calculates the average of 10 students in Test 1 ,Test 2 and Test 3....Values of the marks in all the test for a student should be hardcore.Ialso have to tell the maixmum
menu driven programme
menu driven programme   calculate the area of circle, square, rectangle in menu driven programme in java
hotel management programme in c language?
hotel management programme in c language?  hotel management programme in c language
programme - Java Beginners
programme  java programme to implement stack operation?use stack to check whether a given string is polidrome or not  Hi Friend, Please visit the following link to get the stack implementation: http
compiling programme IJVM
compiling programme IJVM  I TRY AND COMPILE THE PROGRAMME BELOW BUT HAS ERROR APPEAR ALL THE TIME,,CAN ANYONE CORRECT THE CODE AND WRITE UP THE NEXT METHOD FOR POWER IN THE PROGRAME AS WELL...URGENT // Program to read two single
JAVA programme - Java Interview Questions
JAVA programme  Perpare a class "package_example" following the basic functionality of "string" type in JAVA.Use of dynamic character arrays for such class is encouraged.Following is expected from the programme: a.Use of 3
How to add a file in GZIP file format in Java programme.
How to add a file in GZIP file format in Java programme.  Hi please help me. How to add a file GZIP File format in Java program. If example or suggest link for reference then it will be good. thanks,   Hi
making consistency of data member in the whole programme without using static keyword
making consistency of data member in the whole programme without using static keyword  In the below programme i use one boolean variable named check... . But the value of check variable is not maintained in the programme . we can
java
java  where i write java programme and how do i execute the programme
java - Java Beginners
java  write a programme to count the no. of customers in bank using static variable
program - Java Beginners
Program and Programme Difference  What is the difference between program and programmer
c++
c++  write a programme that calculates the area and circumference of a rectangle
menu
menu  fibonaci & prime no. display in menu driven in java programme
java - Java Beginners
java  write a java programme to draw diagram for function f(x)=x*x
chat - Java Beginners
chat   basic concept of chatting.. how will we connect the online users ? requirements for a chatting programme
plz give me answer plz
plz give me answer plz  writw a programme to find rank from an array using doubledimmensionalarray
hi....
hi....  plzz sent me d code for counting vowels in a string... gui programme
STRING.....
STRING.....  plzz sent me d code for counting vowels in a string... gui programme